javascript - MVC jquery dialog not working properly -


when click delete button, popup dialog shows , disappears. not stay

here code:

.cshtml:

@html.actionlink("delete", "deleteorder", "order", new { id = item.orderid }, new { @class = "btn btn-primary btn-delete"} );   <div id="dialog-confirm" title="confirmation dialog" style="display:none">delete order? confirm </div>   <script>   $(document).ready(function () {          $(".btn-delete").click(function () {             var result;                              $("#dialog-confirm").dialog({                 resizable: false,                 height: 140,                 modal: true,                 buttons: {                     "yes": function () {                         $(this).dialog("close");                      },                     "no": function () {                         $(this).dialog("close");                         return false;                     }                 }             });                           }); }); </script> 

handle anchor click , open dialog, if yes set browser url anchor href attribute

$(".btn-delete").click(function(e) {   var ahref = $(this)    $("#dialog-confirm").dialog({      resizable: false,      height: 140,      modal: true,      buttons: {        "yes": function() {          $(this).dialog("close");                   window.location = $(ahref).prop("href");        },        "no": function() {          $(this).dialog("close");        }      }    });        e.preventdefault();  });
<link href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" rel="stylesheet" />  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>    <a href="http://example.com" class="btn-delete">delete item</a>  <div id="dialog-confirm"></div>


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -