开发者

Add a confirmation dialog to ASP MVC view

I want to have a dialog box popup letting a user know of consequences when hitting the continue button, preferably styled better than a standard browser popup.

I got jqdialog, a jquery plugin, and this was my solution:

I have a view with the following HTML:

<form id="formSubmit" action="<%= ResolveUrl("~/Summary/Summary") %>" method="post">
   <input type="button" name="summaryButton" id="bt-confirm" value="Continue »" />
</form>

and I've bound a click event to the button with som开发者_如何学Pythone JQuery:

    $('#bt-confirm').click(function () {
        $.jqDialog.confirm("Are you sure want to continue?",
                function () { CallSubmit(); },  // callback function for 'YES' button
                function () { alert("This intrusive alert says you clicked NO"); }  // callback function for 'NO' button
            );
    });

My CallSubmit() gets called, but the form does not get submitted:

  function CallSubmit() {
      var submitURL = '<%= ResolveUrl("~/Summary/Summary") %>';
      alert(submitURL);

      document.formSubmit.submit();   // This is NOT posting back to the controller          
  }

Is there a better/easier way to do this? What is wrong with my JQuery submit?

Any help would be appreciated.


Try replacing:

document.formSubmit.submit();

with:

$('#formSubmit').submit();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜