germanysbestkeptsecret / Wookmark-jQuery

A jQuery plugin to create a dynamic, multi-column layout.
MIT License
2.64k stars 759 forks source link

How to update layout once Wookmark has been called #206

Open codehandling opened 8 years ago

codehandling commented 8 years ago

What is the right way to update Wookmark layout ?

I am using the jQuery call to Wookmark and I have tried the below to update the layout -

my_wookmark.layout(true);

my_wookmark.updateOptions();

Both give me the Error - Uncaught TypeError: my_wookmark.layout is not a function

Snippet -

    var my_wookmark = $containerList.wookmark(options);

    $containerList.imagesLoaded().always(function() {

        console.log(my_wookmark);
        my_wookmark.layout(true);
        //my_wookmark.updateOptions();
             });
codehandling commented 8 years ago

Also, is there a way I can re-layout the Wookmark grid on the page, if I do not have the woomkark object.

For example, in the previous versions (1.4.8), calling resize() on the window object used to call layout of the Wookmark as well.

$(window).resize();

This does not seem to work in the latest version

Sebobo commented 8 years ago

Thanks a lot for this issue. This is not working anymore as it should.

jQuery doesn't seem to trigger the custom events added with addEventListener. I have to investigate this further and maybe have to add additional event handlers for jQuery.

What you can do now would be this:

container.dispatchEvent(new CustomEvent("refreshWookmark"));
window.dispatchEvent(new CustomEvent("resize"));