English 中文(简体)
Jquery 方言表
原标题:Jquery modal dialog and form submit

我的表格是,在储蓄之前,我需要向用户展示确认的方言。

我已经这样做,拦截了提交职务的表格:

$("#my_form").submit(function(e) {
    if ($("#id").val() > 0) {
        var $dialog = $( <div></div> )
            .html( Are you sure? )
            .dialog({
                autoOpen: false,
                title:  Save New Invoice ,
                modal: true,
                buttons: {
                    "OK": function() {
                        $dialog.dialog( close );
                        $("#my_form").submit();
                    },
                    Cancel: function() {
                        $(this).dialog("close");            
                    }
                }
            });
        $dialog.dialog( open );
        e.preventDefault();
        return false;
    }       
});

但是,科索沃荷兰语并没有正确发挥作用,方言没有结束,表格也没有提交。

如果我改变科索沃局的职能如下,那么方言就会关闭,并显示警示。

"OK": function() {
  $dialog.dialog( close );
  alert( form will be submitted );
},

因此,我猜测,这与<代码>$(“#my_form”)有关,即:方法。

最佳回答

Isn t this like calling your form submit function again and again. I see you are attaching the function to submit functionality, and when you call the submit again,it is invoking the same function.

您的美元“先天——形式”是其他一些形式。 它是否要求一种形式提交另一种形式?

问题回答

问题在于,您的提交书记员总是返回<代码>false,并且有e.preventDefault(,同样值得称道。 两者都将停止提交表格,不论用户是否点击了OK或Cancel。

你们需要改变逻辑,以便在纽扣地(或任何其他事件)上显示你的模式确认,而不是在提交表格上。 然后,如果用户点击ok,你可以打电话到<代码>>>()方法。

$("#submitButton").click(function(e) {
    if ($("#id").val() > 0) {
        var $dialog = $( <div></div> )
            .html( Are you sure? )
            .dialog({
                autoOpen: false,
                title:  Save New Invoice ,
                modal: true,
                buttons: {
                    "OK": function() {
                        $dialog.dialog( close );
                        $("#my_form").submit();
                    },
                    Cancel: function() {
                        $(this).dialog("close");            
                    }
                }
            });
        $dialog.dialog( open );
    }       
});




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签