Reputation: 95
So, I'm using Masonry to make a "fluid" layout in my site but now I've encountered a problem involving its hide and reveal methods.
In an event, I'm making this call:
$container.masonry('hide', $(this));
As you can see, I'm using $(this)
to tell masonry what element to hide through jquery
But apparently, this method does not work with a jquery element?
The error message in my console looks like this:
Uncaught TypeError: Object #<HTMLElement> has no method 'hide' (masonry.pkgd.min.js:9)
I tried looking in the documentation but all it says about the accepted type is:
$container.masonry( 'hide', items )
items Type: Array of Masonry.Items
What is a Masonry.Item supposed to be? And how do I indicate my element as one?
Upvotes: 4
Views: 5517
Reputation: 66
Add this function
// FIX para Masonry
// goes through all children again and gets bricks in proper order
Outlayer.prototype.publicItemize = function() {
// collection of item elements
return this._itemize( this.element.children );
};
now you can do this
// Get correcto list in correct format
var _list = container.masonry("publicItemize");
// Actions on "_list"
// hide elements
container.masonry("hide", _list);
Upvotes: 0
Reputation: 40639
If you read the documentation then you find items
are the array
of elements
.
items Type: Array of Masonry.Items
Try this,
var arr=new Array();
arr.push($(this));
$container.masonry('hide', arr);
Upvotes: 4