Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does jQuery give me an error 'has no method sortable'?

I have a fiddle here

http://jsfiddle.net/WULsZ/1/

I load jQuery first and the code is pretty much straight from the sample so I'm puzzled as to why I'm getting an error

like image 840
Hoa Avatar asked Dec 22 '22 00:12

Hoa


2 Answers

Demo: http://jsfiddle.net/WULsZ/3/

You have to include jQuery Core, then jQuery UI.

<script src="http://dl.dropbox.com/u/12337149/jquery.js"></script>
<script src="http://dl.dropbox.com/u/12337149/jquery-ui.js"></script>

If you include jQuery UI it will try to extend the jQuery Core, and if you include jQuery Core it will overwrite any previous instance of jQuery Core (including the extended jQuery UI code).

Documentation: http://learn.jquery.com/jquery-ui/getting-started/

like image 72
Jasper Avatar answered Dec 26 '22 22:12

Jasper


Here you go working demo: http://jsfiddle.net/WULsZ/7/

Hope this helps, cheers

Missing:

  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

Jquery Code

$(function () {
    $("#sortable").sortable();
    $("#sortable").disableSelection();
});​
like image 38
Tats_innit Avatar answered Dec 26 '22 22:12

Tats_innit