Tuesday, 25 July 2017

Jquery: masonry('hide',element) method with a jquery element



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 # 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?


Answer



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);

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...