Robyflc
Robyflc

Reputation: 1209

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.

Upvotes: 0

Views: 2437

Answers (3)

Matt
Matt

Reputation: 133

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

Upvotes: 0

Robyflc
Robyflc

Reputation: 1209

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!

Upvotes: 2

guy mograbi
guy mograbi

Reputation: 28598

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

Upvotes: 0

Related Questions