asp.net mvc - Multiple posts on click to submit form using jquery dialog and asp mvc3 -
i using following form :
@using (ajax.beginform("saveitem", "itemscontroller", null, new ajaxoptions() { onsuccess = "onformsubmit" }, new { id = "itemsaveform" })) { // form fields below }
and fallowing javascript code manage :
function onformsubmit(content) { $("#dialog-form").dialog("close"); $("#form-data").html(""); //empty form $.post('@url.action("getitemrow", "itemscontroller")', { id: id, adm:true }, function (data) { // update logic.. ignore } }); }
and jquery dialog script witch use submit :
$(function () { $("#dialog:ui-dialog").dialog("destroy"); $("#dialog-form").dialog({ autoopen: false, height: 255, width: 420, modal: true, buttons: { "add": function () { var bvalid = true; $("#itemsaveform").submit(); }, cancel: function () { $(this).dialog("close"); } }, close: function () { } }); });
and every time press add button dialog box... multiple submissions. ideeas why?
i suspect following line origin of problems:
$("#itemsaveform").submit();
how using normal html form:
@using (html.beginform("saveitem", "items", formmethod.post, new { id = "itemsaveform" })) { ... }
and configure add
button on dialog this:
'add': function () { var bvalid = true; var form = $('#itemsaveform'); $.ajax({ url: form.attr('action'), type: form.attr('method'), data: form.serialize(), success: onformsubmit }); }
Comments
Post a Comment