Define/call a function in isotope onLayout

人走茶凉 提交于 2019-12-07 03:10:32

You can bind custom events on to elements like so:

$('#container').bind('my_event', function ()
{
    alert('my_event has just fired!');
});

And then call it with .trigger():

$('#container').trigger('my_event');

Using this, you should be able to set up what you want pretty easily, I think.


Update:

Instead of calling this code:

$('#container').isotope({
   onLayout: function( $elems ) {
    // `this` refers to jQuery object of the container element
    console.log( this.height() );
    // callback provides jQuery object of laid-out item elements
    $elems.css({ background: 'blue' });
    }
});

Call this:

$('#container').isotope({
   onLayout: function( $elems ) {
        // `this` refers to jQuery object of the container element
        console.log( this.height() );
        // callback provides jQuery object of laid-out item elements
        $elems.css({ background: 'blue' });
        $("#container").width(); 
        $("#head").animate({ width: newWidth}, "fast");
    }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!