-->

jQuery Masonry conflict with jQuery UI Sortable

2019-02-15 20:19发布

问题:

jQuery UI Sortable is not working when using Masonry. Any idea how to avoid this conflict? Any help would be appreciated.

回答1:

I think i had a similar problem.

I managed to fix it by simply recalling masonry within the code for setting up the sortable elements. (there might be a better way, i'm not sure?)

$(function() {
        $("#youritem").sortable({ opacity: 0.9, cursor: 'move', update: function() {
            var order = $(this).sortable("serialize") + '&action=updateRecordsListings'; 
            $.post("dosomething.php", order, function(theResponse){
                       //you can see that i've re-called masonry once the sortable object has been moved                
                        $('#youritem').masonry({columnWidth: 200, itemSelector: 'youritem' });
            });                                                              
        }                                 
        });
    });

Hopefully that helps you out – if there is another way i'd also like to know.



回答2:

I also had similar problem, but then i found a working Masonry&Sortable&resizable example:

http://tyler-designs.com/masonry-ui/

Not perfect, but it's a good starting point.



回答3:

Use gridster — it works like a charm and very intuitive