“类型错误:jQuery.easing [this.easing]不是jQuery 1.9.1中的函数”

时间:2013-03-30 14:11:43

标签: jquery jquery-ui jquery-plugins

这是第一次在太多月(腮红),我升级了我的jQuery东西。我现在在:

  • 的jquery-1.9.1.js
  • jquery-ui-1.10.2.custom.js(使用了ThemeRoller,包含了所有组件,包括效果核心,在其描述中提到了缓动)

我还升级到最新版本的jquery.multiselect和jquery.multiselect.filter插件。当我尝试关闭其中一个多选菜单时,我收到此错误:

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

请注意,虽然我在发生错误时使用了multiselect插件,但实际错误在主jQuery文件中。代码是:

/*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*/ }

我忘记更新某个文件了吗?谷歌搜索,其他有同样抱怨的人似乎都试图使用某种额外的缓动插件,但我不是。

6 个答案:

答案 0 :(得分:14)

首次升级到jQuery 1.9时,您的网站上的各种动画都会出现此错误。+因为缓动效果名称已更改!!!

参见http://api.jqueryui.com/easings/ 没有帮助的是jQueryUI.com网站中的旧示例尚未更新,导致人们认为旧的动画示例名称是正确的。

示例:手风琴小组“bounceslide”动画现在是名为“ easeOutBounce ”的近似版本。截至撰写本文时,字符串“bounceslide”仍然在网站的示例中: http://api.jqueryui.com/accordion/#option-animate

我只是意识到动画名称在遵循动画类型中提到的超链接并在我的代码中尝试新名称后发生了变化。

答案 1 :(得分:10)

包括:

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

注意:如果需要,请更新jquery UI版本。

答案 2 :(得分:2)

无效的第二个参数问题

如果这有助于某人绊倒这个问题,就像我收到此错误时所做的那样,我会添加另一个可能的解决方案。我的错误是由于fadeIn函数的第二个参数不是动画完成时要执行的“回调”函数。如果第二个参数不是函数,jQuery期望它是一种要使用的缓动。我的第二个论点错误地是一个对象 - 我认为它是一个函数

所以,对我来说,

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

成为:

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

注意,传递给我的匿名enter函数的参数更改。重要的是在我的情况下,这些变量是AngularJS注入,所以它们的顺序很重要,而不是它们的名字。

答案 3 :(得分:1)

错误地使用lines[0] gives "Alice was beginning to get very tired of sitting by her sister on the" lines[1] gives "bank, and of having nothing to do: once or twice she had peeped into the" and so on. 之类的效果方法时,由于自变量反转会引发错误,因为这会导致调用无效缓动。

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

.show(easing, duration)
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; }

答案 4 :(得分:0)

感谢@ Legionar的评论,升级到他建议的版本1.13对我有用:

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

UPDATE 在此版本中outerHeight()函数的使用导致小部件位置错误,因为它错过了css位置top,将第573行更改为以下将会出现问题固定:

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

答案 5 :(得分:0)

这与版本完全无关。

我有这段代码,并得到了相同的错误:

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

问题是我传递给切换功能的参数。所以我改为:

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

因此请注意在调用jQuery-api时传递给函数的参数。希望这会有所帮助。