asp.net mvc - jquery button in pop up -
i used index.js file write code create , open popup on button click. partial view invoked popup.
$("#createform").dialog({ autoopen: false, modal: true, width: 550, height: 420, open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); } }); $(".buttoncreate").button().click(function() { $.ajax({ // call createpartialview action method url: "/purchaseinvoice/additempartial", type: 'get', success: function(data) { $("#createform").dialog("open"); $("#createform").empty().append(data); $("#editform").hide(); }, error: function() { alert("something seems wrong"); } }); });
the button in popup used invoke function .js file. button not working first time when popup opens when popup opens after closing popup esc button working right .
$("#popupadd").click(function() { // on submit button click close dialog box $("#createform").dialog("close"); // set inserted vlaues var item = $("#ddlitem").val().tostring(); var quantity = $("#quantity").val(); var price = $("#price").val(); var hdnid = $("#hdninvoiceid").val(); // call create action method $.post('/purchaseinvoice/create', { "ddlitem": item, "quantity": quantity, "price": price, "hdninvoiceid": hdnid }, function() { alert("data saved successfully"); window.location.reload(true); }); });
the partial view used popup on button click partial view called controller , showed in popup.
to selector work on item dynamically added page tie document this
$(document).on('click', '#popupadd', function(){...
Comments
Post a Comment