简体   繁体   English

“TypeError: jQuery.easing[this.easing] is not a function” in jQuery 1.9.1

[英]“TypeError: jQuery.easing[this.easing] is not a function” in jQuery 1.9.1

For the first time in too many months (blush), I upgraded my jQuery stuff.几个月来第一次(脸红),我升级了我的 jQuery 东西。 I'm now on:我现在在:

  • jquery-1.9.1.js jquery-1.9.1.js
  • jquery-ui-1.10.2.custom.js (used ThemeRoller, and included all components, including the Effects Core, which mentions easing in its description) jquery-ui-1.10.2.custom.js(使用 ThemeRoller,包括所有组件,包括 Effects Core,它在描述中提到了缓动)

I also upgraded to the most recent versions of jquery.multiselect and jquery.multiselect.filter plugins.我还升级到最新版本的 jquery.multiselect 和 jquery.multiselect.filter 插件。 When I try to close one of the multiselect menus, I get this error:当我尝试关闭多选菜单之一时,出现此错误:

TypeError: jQuery.easing[this.easing] is not a function
jquery-1.9.1.js (line 9033)

Note that although I'm using the multiselect plugin when the error occurs, the actual error is in the main jQuery file.请注意,虽然我在发生错误时使用了多选插件,但实际错误在主 jQuery 文件中。 The code is:代码是:

/*9031*/ if ( this.options.duration ) {
/*9032*/   this.pos = eased = jQuery.easing[ this.easing ](
/*9033*/     percent, this.options.duration * percent, 0, 1, this.options.duration
/*9034*/   );
/*9035*/ }

Did I forget to update some file?我忘记更新一些文件了吗? Googling about it, others with the same complaint seem to all be trying to use some sort of additional easing plugin, but I'm not.谷歌搜索,其他有同样抱怨的人似乎都在尝试使用某种额外的缓动插件,但我不是。

This error could happen in various animations throughout your site when first upgrading to jQuery 1.9.+ because the easing effect names have changed !!!首次升级到 jQuery 1.9.+ 时,整个站点的各种动画中可能会发生此错误,因为缓动效果名称已更改!!!

See http://api.jqueryui.com/easings/ What doesn't help is that the old examples in the jQueryUI.com site havent been updated, leading folks to think that the old animate example names are correct.请参阅http://api.jqueryui.com/easings/没有帮助的是 jQueryUI.com 站点中的旧示例尚未更新,导致人们认为旧的动画示例名称是正确的。

Example: accordion panels "bounceslide" animation is now a close version of something called ' easeOutBounce '.示例:手风琴面板“bounceslide”动画现在是名为“ easeOutBounce ”的接近版本。 The string "bounceslide" is still in the sites' example as of this writing: http://api.jqueryui.com/accordion/#option-animate .在撰写本文时,字符串“bounceslide”仍在网站的示例中: http ://api.jqueryui.com/accordion/#option-animate。

I only realised the animation names had changed after following the hyperlink mentioned in the animate types and trying the new names out within my code.在遵循动画类型中提到的超链接并在我的代码中尝试新名称后,我才意识到动画名称已更改。

Include:包括:

<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>    

Note: update the jquery UI version if needed.注意:如果需要,更新 jquery UI 版本。

Invalid 2nd Argument Issue无效的第二个参数问题

In case this helps someone stumbling upon this question like I did when I got this error, I'll add another possible solution.如果这有助于像我遇到此错误时那样绊倒这个问题的人,我将添加另一个可能的解决方案。 My error was due to the fact that my 2nd argument to the fadeIn function was not a "callback" function to be executed on completion of the animation.我的错误是由于我对fadeIn函数的第二个参数不是在动画完成时执行的“回调”函数。 If the 2nd argument is not a function, jQuery expects it to be a type of easing to use.如果第二个参数不是函数,jQuery 期望它是一种易于使用的类型。 My 2nd argument was mistakenly an object - I thought it was a function .我的第二个参数错误地是一个对象——我认为它是一个函数

So, for me,所以,对我来说,

return {
  enter: function(element,classes,done){ //classes variable incorrectly added, making done an object
    element.fadeIn(1000,done);
  }
};

became:变成了:

return {
  enter: function(element,done){ //remove classes variable as wasn't right for this situation - done is now a function
    element.fadeIn(1000,done);
  }
};

Note, the change in arguments passed into my anonymous enter function.请注意,传入我的匿名enter函数的参数更改。 Importantly in my case, these variables were AngularJS injections, so the order they were in was important, not so much their name.重要的是,在我的例子中,这些变量是 AngularJS 注入,所以它们的顺序很重要,而不是它们的名字。

The error can be provoked by argument inversion when using an effect method wrongly like .show(duration, easing) as it leads to a call of an invalid easing.当错误地使用像.show(duration, easing)这样的效果方法时,参数倒置可能会引发错误.show(duration, easing)因为它会导致调用无效的缓动。

The correct notation is .show(easing, duration) https://api.jquery.com/show/正确的符号是.show(easing, duration) https://api.jquery.com/show/

 var duration = 'slow', easing = 'linear'; $("#correct").click(function() { $("p").show(duration, easing); }); $("#error").click(function() { $("p").show(easing, duration); // fails -> see error in console });
 p { background: yellow; }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> $("p").show( <button id="correct">duration, easing</button> <button id="error">easing, duration -> ERROR</button> ) <p style="display: none">Hello</p>

Thanks to @Legionar's comment, upgrade to his suggested version 1.13 worked for me:感谢@Legionar 的评论,升级到他建议的1.13版对我1.13

https://github.com/ehynds/jquery-ui-multiselect-widget/archive/1.13.zip

UPDATE in this version the usage of outerHeight() function causes the widget to position wrong because it misses css position top , changing line#573 to following will get the issue fixed:更新此版本中,使用outerHeight()函数导致小部件定位错误,因为它错过了 css 位置top ,将 line#573 更改为以下将解决问题:

top: pos.top + button.outerHeight(false),

This has absolutely nothing to do with versions.这与版本完全无关。

I had this code and got the same error:我有这个代码并得到同样的错误:

$("#consoleBtn").click(function(){
    $("#consolePanel").toggle("display", {  from : { display: "block" }, to : { display: "none" } });
});

The problem was the arguments I passed to the toggle function.问题是我传递给切换函数的参数。 So I changed to:所以我改为:

$("#consoleBtn").click(function(){
    $("#consolePanel").toggle();
});

So be mindful of the arguments passed to your function when calling jQuery-api.所以在调用 jQuery-api 时要注意传递给你的函数的参数。 Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM