简体   繁体   中英

Jquery ui sortables don't work

I'm using jquery ui to make a sortable list but it doesn't work and I just can't understand why. The ul element receives the class 'ui-sortable' but nothing happens.

I made an example as the original js has many more unrelated objects.

The example is here . To make it 'work' just click the button with 'editar' in it.

After wasting a whole weekend with this issue, I ended up understanding what happened. As this comment points out: when adding elements in the dom using, .html(), it loses its events and data and that's why I wasn't able to clone a previously sortable ul.

I solved my issue assuring that the list was already at the dom before applying the sortable method to it.

Fabrício and Guy, thanks a lot for your help!

If you switch the fiddle to use JQuery 1.7.2 and JQuery ui 1.8.18 it works fine. probably compatibility issues. You can see it in my version of your fiddle

The error I saw was

Uncaught TypeError: Object function ( selector, context ) {
        // The jQuery object is actually just the init constructor 'enhanced'
        return new jQuery.fn.init( selector, context, rootjQuery );
    } has no method 'curCSS' jquery-ui.js:84
(anonymous function) jquery-ui.js:84
(anonymous function) jquery-git.js:5473
jQuery.extend.grep jquery-git.js:709
winnow jquery-git.js:5472
jQuery.fn.extend.filter jquery-git.js:5271
$.fn.extend.scrollParent jquery-ui.js:83
$.widget._mouseStart jquery-ui.js:3026
$.widget._mouseMove jquery-ui.js:677
$.widget._mouseDown._mouseMoveDelegate jquery-ui.js:650
jQuery.event.dispatch jquery-git.js:3060
jQuery.event.add.elemData.handle.eventHandle

I had this same issue. In my case it was just a matter of finding and removing a duplicate jQuery include <script> tag.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM