Error jquery-ui draggable Cannot read property 

2019-01-25 05:21发布

I got some troubles to make work jquery-ui draggable. I will share with you my solution, this is the best solution?

I just insert this to test before I start my real work.

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

and

  $('img').draggable();

Like here: http://jsbin.com/eqowet/2/

But I got a error:

Error: Uncaught TypeError: Cannot read property 'msie' of undefined.

5条回答
一纸荒年 Trace。
2楼-- · 2019-01-25 05:40
爷的心禁止访问
3楼-- · 2019-01-25 05:44

msie is the flag on the jQuery.browser property

jQuery.browser was deprecated since version 1.3 and was removed in jQuery 1.9.0

Since you're using the latest version of hosted jQuery, your library was auto-upgraded to 1.9.0 hence the error.

As you've already realized, reverting back to 1.8.3 (or earlier version) fixes the issue; the real solution, however, is to stop using jQuery.browser

查看更多
家丑人穷心不美
4楼-- · 2019-01-25 05:46

I try a lot of examples but all isn't working, just the same message, that I realized the version 1.8.24 isn't compatible with the last jQuery version. I have changed for it and voilà is working now.

<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>

Like here: http://jsbin.com/eqowet/3/

查看更多
混吃等死
5楼-- · 2019-01-25 05:46

I got this error for an older version of jquery mobile. If you are using an old JQM, you need to update. If you are on Rails you can use the jqueryhttps://github.com/tscolari/jquery-mobile-rails

If you use the rails gem right now, be sure to get the 1.3 beta 1 to get this fix:

gem 'jquery_mobile_rails', "~> 1.3.b1"
查看更多
我命由我不由天
6楼-- · 2019-01-25 05:51

Got the same error with "sortable". So, make sure that all dependant scripts are included, also should be the right sequence.

jquery.min.js
jquery.ui.core.js
jquery.ui.sortable.min.js

For example to make it work on Joomla you may do like this:

$doc =& JFactory::getDocument();
$doc->addScript('/media/jui/js/jquery.min.js');
$doc->addScript('/media/jui/js/jquery.ui.core.js');
$doc->addScript('/media/jui/js/jquery.ui.sortable.min.js');
查看更多
登录 后发表回答