TaG*_*ang 46 asp.net-mvc jquery
请帮我.当我jQuery
在ASP.NET MVC中使用时,这是一个错误.
未捕获的TypeError:((x.event.special [i.origType] ||(中间值)).handle || i.handler).apply不是函数Uncaught TypeError:((x.event.special [i.origType ] ||(中间值)).handle || i.handler).apply不是函数
导致这种情况的代码是:
$('#btnClick').click(function(){ //code })
Run Code Online (Sandbox Code Playgroud)
smo*_*nes 45
在我的情况下,错误是由绑定事件到不存在的函数引起的.我已经删除了我不知道被绑定到事件的函数.
请参阅下面的代码段:
var foo = {
bar1: function(){
alert('working');
}
};
// Working
$('body').on('click', '.my-button', foo.bar1);
// Not Working because bar2 doesn't exist
$('body').on('click', '.my-button', foo.bar2);
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span class="my-button">Click me</span>
Run Code Online (Sandbox Code Playgroud)
它会产生:
未捕获的TypeError:((n.event.special [g.origType] ||(中间值)).handle || g.handler).apply不是函数
小智 9
如果这对任何人都有帮助,那也可以因为事件处理函数被声明两次.
我的一位同事将事件编码为"开启"两次并且我解决了(顺便说一句傻瓜挑战).
例如,如果您输入错误:
$(document).on('change', '#selectInput').on('change', '#selectInput', function () {});
Run Code Online (Sandbox Code Playgroud)
一定是:
$(document).off('change', '#selectInput').on('change', '#selectInput', function () {});
Run Code Online (Sandbox Code Playgroud)
就我而言,我输入了
$('body').click('click','.delete_item',function(e){})
Run Code Online (Sandbox Code Playgroud)
当我打算输入:
$('body').on('click','.delete_item',function(e){})
Run Code Online (Sandbox Code Playgroud)
更改它click
以on
消除错误。
归档时间: |
|
查看次数: |
50317 次 |
最近记录: |