JavaScript:在MVC3's PartialView没有't关闭

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

本文关键字:没有 关闭 PartialView JavaScript MVC3      更新时间:2023-09-26

我的PartialView中JS的confirm有问题。如果页面不是PartialView,下面的代码可以正常工作,但是,如果页面是PartialView的话,如果我在确认对话框上单击"确定",它不会关闭。为什么?

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

编辑

看起来这是双重确认。。。像这里一样,jQuery/Javascript确认出现两次

解决方案:

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