问题
I've found a few fixes for this issue already but they aren't specific to this. I've read simple things like Sortable() needs to be lowercase. Of course, I do not have it set as uppercase first.
I already had this working and then suddenly it decided to spit out the following in the console Uncaught TypeError: Object [object Object] has no method 'sortable'
on line:210 which correspondes to:
// Line 210 is below $('.sortable').sortable({ stop: get_post_order }).disableSelection(); // Check new order function get_post_order() { var post_list = [], pids; $('.inner-pop-list li a').each(function() { pids = $(this).attr('rel'); post_list.push(pids); }); $('.export').attr('href', '?format=pdf&pids='+post_list); }
It should be updating the post_list array after the list has been reordered. The get_post_order
is not running at all. I've tried adding the function directly into the stop: function() {...}
but still no change.
Any ideas, I'm pretty stumped.
Thanks
回答1:
Fixed, sometimes getting fresh approaches from other people leads you to the answer. Thanks for your help. It made me look at the header of my site. I noticed I'd already added the sortable() declaration in the header. Then I'd referenced sortable again in an external script (which was line 210) causing a conflict.
So the answer is, reference sortable() once!
回答2:
It is possible that your javascript code is not within $(document).ready, and it is being executed before the ui library has loaded.
来源:https://stackoverflow.com/questions/12952353/uncaught-typeerror-object-has-no-method-sortable