Jquery UI error - f.getClientRects is not a function

匿名 (未验证) 提交于 2019-12-03 02:49:01

问题:

I'm trying to make Jquery UI work, but it doesn't. Here's what happens. I'm loading dependencies:

<script src="assets/src/js/angular/angular.js"></script> <script src="assets/src/js/angular-animate/angular-animate.js"></script> <script src="assets/src/js/angular-route/angular-route.js"></script> <script src="assets/src/js/jquery/dist/jquery.js"></script> <script src="assets/src/js/jquery-ui/jquery-ui.js"></script> <script src="assets/src/js/app.js"></script> <script src="assets/src/js/main.js"></script> 

That's my main.js file:

$(function () {     $("input[type=submit]")         .button()         .click(function (event) {             event.preventDefault();         }); });   $(function () {     $("#circum").buttonset(); });  $(function () {     $("#dialog-message").dialog({         modal: true,         buttons: {             Ok: function () {                 $(this).dialog("close");             }         }     }); }); 

When I run the code in Brackets Jquery UI is loaded but doesn't work, however, when I comment my main.js file out and then bring it back that's the error I get in the console and UI is suddenly working. It's extremely weird.

jQuery.Deferred exception: elem.getClientRects is not a function TypeError: elem.getClientRects is not a function at jQuery.offset (http://127.0.0.1:27530/assets/src/js/jquery/dist/jquery.js:9779:14) at Object.getWithinInfo (http://127.0.0.1:27530/assets/src/js/jquery-ui/jquery-ui.js:1157:26) at jQuery.$.fn.position (http://127.0.0.1:27530/assets/src/js/jquery-ui/jquery-ui.js:1179:23) at _position (http://127.0.0.1:27530/assets/src/js/jquery-ui/jquery-ui.js:8709:17) at ._position (http://127.0.0.1:27530/assets/src/js/jquery-ui/jquery-ui.js:415:25) at open (http://127.0.0.1:27530/assets/src/js/jquery-ui/jquery-ui.js:8334:8) at .open (http://127.0.0.1:27530/assets/src/js/jquery-ui/jquery-ui.js:415:25) at _init (http://127.0.0.1:27530/assets/src/js/jquery-ui/jquery-ui.js:8210:9) at ._init (http://127.0.0.1:27530/assets/src/js/jquery-ui/jquery-ui.js:415:25) at _createWidget (http://127.0.0.1:27530/assets/src/js/jquery-ui/jquery-ui.js:587:8) undefined 

I've found this thread discussing the issue but still wasn't able to fix it.

Github

Cheers.

回答1:

What version is your jQuery UI? I had the same issue with jQuery UI 1.11.4 and jquery 3.0. After installing jQuery UI 1.12.0-rc.2, the problem was fixed.



回答2:

Adding the jQuery 3 Migrate Plugin resolves this issue as noted here, updated UI will be coming out soon.



回答3:

Turns out this is a compatibility between jQuery 3.x.x and jQueryUI prior to 1.12.0.

including below script resolved the issue for me.

https://code.jquery.com/jquery-migrate-3.0.0.min.js



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!