javascript - How to achieve recursive call - jquery -
javascript - How to achieve recursive call - jquery -
i have custom created dialog module. passing mvc view
called cart
module. cart view
has link called 'create new contat'
clicking on view(cart)
replaced view(contact
) using ajax call. contact view
has button called cancel
. when user clicks on cancel old view(cart)
replace existing view(contact
). problem facing after replacing view none of links or buttons work on view. can body pls directed me towards improve way of doing this.
pasted below code.
$(document).on('click', '.ddlcart li', function(e) { var ddlselectedval = $(this).attr('id'); var selectedlistinscount = selected_listings.length; var selectedmlsnums = selected_listings.join(); var agentid = $("#agentid").val(); var action; var environmenturl = $("#environmenturl").val(); var postdata = { agentid: agentid, mlsnums: selectedmlsnums, actiontypevalue: “preaddtocart” }; var close = function (event, ui) { $('#dvmodaldialog').dialog("close"); } var open = function (event, ui) { var url = environmenturl + "mlsreports/stats/searchcontacts"; $("#btncart_cancel").on("click", function () { $('#dvmodaldialog').dialog("close"); }); $("#btncart_submit").on("click", function () { var url = environmenturl + "mlsreports/stats/cart"; //send info using post , set results in div $.post(url, { agentid: agentid, mlsnums: selectedmlsnums, actiontypevalue: "addtocart" }, function (data) { // replace current info data ajax phone call div. $("#dvmodaldialog").empty().append(data); }); }); $("#lnkcreatenewcart").on("click", function () { var url = environmenturl + "mlsreports/stats/cart"; //send info using post , set results in div $.post(url, { actiontypevalue: "preaddoreditcontact" }, function (data) { //debugger; // replace current info data ajax phone call div. $("#dvmodaldialog").empty().append(data); $("#btncancelcontact").on("click", function () { ////********** replace view (contact) view (cart). // in cancel event loading previous page.i having problem here. after post none of controls work. $.post(url, { actiontypevalue: "preaddtocart" }, function (data) { //debugger; // replace current info data ajax phone call div. $("#dvmodaldialog").empty().append(data); }) }); }); }); }; if (ddlselectedval == "addtocart") { var rd = mod.reportsdialog({ title: 'add cart', close: close, open: open }); rd.url = environmenturl + "/mlsreports/stats/cart"; rd.targetelement = '#dvmodaldialog'// '#dvsendemail' rd.formname = '#frmcart' rd.postdata = postdata rd.open(); } });
javascript jquery asp.net-mvc modal-dialog
Comments
Post a Comment