twitter bootstrap - How can I make an Ajax Actionlink to call a bootbox dialog? -


i have table containing loop inside mvc view page. each row has delete button contains this:

@ajax.actionlink("delete", "deleterecord", new { id = item.id }, new ajaxoptions { insertionmode = insertionmode.replace, updatetargetid = "divlist" }) | 

it works fine, i'd implement confirm dialog. found bootbox can used modal confirm dialogs i'm not sure how can implement this:

// 1. when clicked, confirm <a class="alert" href="#">delete</a>  <script> $(document).on("click", ".alert", function (e) {     bootbox.confirm("are sure?", function (result) {         if (result == true) {              // 2. actionlink depending on id          }     }); }); 

any kind of appreciated.

ajaxoptions() has 'confirm' option can set confirm message.

ajaxoptions opts = new ajaxoptions() {     confirm = "are sure?"         } 

but should not use ajax.actionlink if want integrate custom modal. make link or @url.action , set listener.

$('.class').click(function () {     //open modal     //if clicked yes     $.ajax({        ...     }); }); 

or try use onbegin property of ajaxoptions , set modal window logic. , return false if no confirm.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -