JQuery: masonry method ('hide', element) with jquery element

So, I use Freemasonry to create a "liquid" layout on my site, but now I am faced with a problem associated with its methods of hiding and disclosing.

In the case, I make this call:

$container.masonry('hide', $(this)); 

As you can see, I use $(this) to tell the stone cluster which element to hide through jquery

But apparently this method does not work with jquery element?

The error message in my console is as follows:

 Uncaught TypeError: Object #<HTMLElement> has no method 'hide' (masonry.pkgd.min.js:9) 

I tried to look into the documentation , but all that it says about the accepted type:

 $container.masonry( 'hide', items ) 

Elements Type: Array of Freemasonry. Items

What is freemasonry. Is this supposed to be? And how to specify your element as one?

+4
source share
2 answers

If you read the documentation, you will find items array elements .

Type: Array of Masonry.Items

Try it,

 var arr=new Array(); arr.push($(this)); $container.masonry('hide', arr); 
+4
source

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 it

 // Get correcto list in correct format var _list = container.masonry("publicItemize"); // Actions on "_list" // hide elements container.masonry("hide", _list); 
0
source

Source: https://habr.com/ru/post/1486463/


All Articles