Sunday 15 June 2014

jquery - Confirmation to pause form submit until Ok has beenpushed -


I have a form that pops up a confirmation dialog (you want to continue) But the form is being sent to my controller at the same time, which if you did not hit yes or not, even if the processing started. I stop the form until Javascript Confirmation / Show @using (@textboxfor (m = & gt; @using (Html.BeginForm ("Process", "Home", FormMethod.Post, new {id} = "MyForm"}) {@ Html.TextBoxFor (m = & gt; ; M.Name); // Other Form Control ... & lt; Input id = "submit" type = "submit" value = "apply changes" /> }

Javascript: (using jquery-ui)

  $ (function () {$ ("# confirm") dialog ({autoopen : False, button: {"OK": function () {$ (this) .dialog ("off"); $ ('#moform'). Submit (); Return;}, Cancel: Function () $ {(This ("Close") .dialog ("Close"); event.preventDefault (); Return Back;}}}); $ ("# Submit") Click (function () {$ (" "Confirm"). Dialog ("open");});});    

< P> Stop the default task immediately, then press OK button Submit. < Pre> $ (function () {$ ("confirm"). Dialog ({autoOpen: incorrect, button: {"OK": function () {$ (this) .dialog ("Close" $ "('#mayform') [0] Submit ();}, Cancel: Function () {$ (this) .dialog (" close ");}}}) $ (" # MyForm "). (Function (e) {e.preventDefault (); $ ("# confirm"). Dialog ("open");});});

No comments:

Post a Comment