jQuery-IE在显示对话框时给出[object Object]错误 [英] jQuery - IE gives [object Object] error when displaying dialogs

查看:210
本文介绍了jQuery-IE在显示对话框时给出[object Object]错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在制作一个页面,其中jQuery对话框显示了一些输入,稍后javascript将它们显示出来.在以下情况下可以正常工作:


I'm making a page where a jQuery dialog comes up with some inputs and later javascript displays them. This works fine in:

  • Chrome 31
  • 歌剧18
  • Safari 5(这确实很旧,因为我在Windows上使用safari)

但是,它在Internet Explorer 7-11或Firefox 26中不起作用.

However, it does not work in Internet Explorer 7-11, or Firefox 26.

演示: http://bit.ly/1chhvBN

IE 11中的错误:

DEMO: http://bit.ly/1chhvBN

Error in IE 11:

有什么想法吗?预先谢谢你.

Any Ideas? Thank you in advance.

推荐答案

不要使用href属性将事件处理程序绑定到元素.您有jQuery,使用它来绑定事件.

Do not use href attributes to bind event handlers to elements. You have jQuery, use that to bind the events.

<div id="favorites">
    <a href="#" class="add">+</a>
</div>

然后,只需:

$('#favorites a').click(function(e){
    e.preventDefault();
    $( '#dialog' ).dialog({width: 850, height: 300});
});

使用addToFavorites按钮执行相同操作.

Do the same with the addToFavorites button.

<a href="#" class="addToFavorites button" style="width: 150px;">Add to My Favorites</a>

然后做:

$('.addToFavorites').click(function(e){
    e.preventDefault();
    addToFavorites();
});

这是一个演示: http://jsfiddle.net/aRpcL/3/

这篇关于jQuery-IE在显示对话框时给出[object Object]错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆