简体   繁体   中英

JavaScript: Confirm in MVC3's PartialView doesn't close

I have a problem with the JS's confirm in my PartialView. The code below works fine if the page is NOT a PartialView, but, if the page IS a PartialView, if I click OK on that confirm dialog it does not close. Why ?

$("input.del-file-cb").live('click',function () {
      if ($(this).is(':checked')) {
          var ans = confirm('Are You sure ?');

          if (ans) {
                   ....             
          } else {
                 $(this).attr("checked", false);
          }
      }
 });

Edit

It looks that it is a double confirmation... like here jQuery/Javascript confirm coming up twice

The solution:

$("input.del-file-cb").live('click',function (e) {
      if ($(this).is(':checked')) {
         e.preventDefault();

... the rest of the code ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM