JQuery的按钮点击不工作后,阿贾克斯形式的IE浏览器提交 [英] JQuery button click not working after ajax form submit on IE

查看:70
本文介绍了JQuery的按钮点击不工作后,阿贾克斯形式的IE浏览器提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些麻烦提交使用JQuery AJAX表格后单击按钮。这里是我的HTML如下:

I am having some trouble getting a button clicked after submitting a form using JQuery ajax. Here is what my html looks like:

<div>
   <!-- normal HTML buttons that are overridden by JQuery for styling purposes -->
   <!-- Here, on render, the HTML button is hidden and a similar JQuery button is shown on       the DOM -->
</div>
<div>
    <!--- Stuff generated by a third-party tool --> 
</div>
<div>
    <!--- Our form loaded using JQuery --> 
</div>

以上提到的按钮居然把到DOM的第三方工具和网页渲染,我们接管他们通过隐藏按钮和生产JQuery的按钮,然后模仿原按钮的行为。所以,基本上,用户将填补第三方东西形式,填写表单,然后点击JQuery的按钮,在这之前,我们先提交表单到服务器,然后单击原始按钮,使第三方工具可以提交自己的东西。这里是code提交表单:

The buttons mentioned above are actually put into the DOM by the third-party tool and on page render we take over them by hiding the buttons and producing JQuery buttons that then mimic the original buttons' behavior. So, basically, the user would fill in the 3rd party stuff in the form, fill our form and then click the JQuery button, upon which, we first submit our form to the server and then click the original button so that the 3rd party tool can submit it's own stuff. Here is the code for submitting our form:

clickoriginalbutton = function(passedButton)  {
    $(passedButton).click();

},
//save our data
submitourform = function(buttonreference) {
    $('#our_form').ajaxForm(options);

    $('*').button('disable');
    $('#our_form').ajaxSubmit({
        iframe: true,
        dataType: 'json',
        success: function(data){
            if (data.status == 'success') {
                         clickoriginalbutton (getOrigButton(buttonreference));
                };                                              
            }
        });
}

正如你所看到的,点击拯救我们的形式成功后,原来的按钮。按钮单击工作正常,在FF,但无法在IE浏览器。我可以看到,我们的表单提交,并成功回来,但IE浏览器只是不火原按一下按钮。我已经检查了所有引用到按钮都是精品。我还搜查了论坛,在这里,发现现场/委托等,但不知道他们是否会为我工作,因为我们的按钮总是在那里,他们没有通过渲染。阿贾克斯 - 事实上,没有什么是通过渲染。阿贾克斯后的第一个负载。所以,不知道为什么按钮点击不工作的IE浏览器,而它的工作原理在FF。任何想法,为什么这会发生。

As you can see, the original button is clicked upon success of saving our form. The button click works fine in FF, but fails in IE. I can see that our form is submitted and the success comes back, but IE just does not fire the click of the original button. I have checked that all the references to the buttons are fine. I also searched in the forums here and found live/delegate etc., but not sure if they will work for me because our buttons are always there, they are not rendered via. ajax -- in fact, nothing is rendered via. ajax after the first load. So, not sure why the button click is not working on IE while it works on FF. Any ideas why this would be happening.

谢谢, 尼廷

推荐答案

因此​​,它看起来像在IE浏览器的JQuery无法click事件绑定到原来的按钮。我改变clickoriginalbuttons code和使用普通的JavaScript点击,并开始在IE工作。现在我的code是这样的:VAR origButton =的document.getElementById($(daButton).attr(ID)); origButton.click();现在的问题是解决了:)

So it looks like in IE JQuery was not able to bind the click event to the original button. I changed clickoriginalbuttons code and used normal javascript click and it started working in IE. Now my code is like this: var origButton = document.getElementById($(daButton).attr("id")); origButton.click(); The problem is solved for now :)

这篇关于JQuery的按钮点击不工作后,阿贾克斯形式的IE浏览器提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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