JQUERY实时确认问题

JQUERY实时确认问题,jquery,confirm,Jquery,Confirm,我的问题与动态应用到我正在运行确认的页面的元素有关。代码正确地指向元素并询问确认部分,但是问题是如果我选择Yes,我不知道返回值隐藏在哪里,它不会像我下面的想法那样在类中设置,也不会返回任何类型的值 有人知道我如何从确认中获得某种形式的返回值,用于我要删除的元素吗 $('.deleteMe').live('click', function() { confirmFunction(this); if ($(this).hasClass('confirm')

我的问题与动态应用到我正在运行确认的页面的元素有关。代码正确地指向元素并询问确认部分,但是问题是如果我选择Yes,我不知道返回值隐藏在哪里,它不会像我下面的想法那样在类中设置,也不会返回任何类型的值

有人知道我如何从确认中获得某种形式的返回值,用于我要删除的元素吗

    $('.deleteMe').live('click', function() {

        confirmFunction(this);
        if ($(this).hasClass('confirm')){ alert("yea");} else {alert("no");}
    });

    function confirmFunction(element) {
        $(element).confirm({
          msg:'Confirm Action!<br />',
          stopAfter:'ok',
          eventType:'click',
          timeout:5000,
          buttons: { ok:'Yes', cancel:'No', separator:' - '}
        });
    }
$('.deleteMe').live('click',function()){
确认功能(本);
if($(this.hasClass('confirm')){alert(“yes”);}else{alert(“no”);}
});
函数确认函数(元素){
$(元素)。确认({
消息:“确认操作!
”, 停止后:'好', 事件类型:'单击', 超时:5000, 按钮:{确定:'Yes',取消:'No',分隔符:'-'} }); }
根据我对插件页面上示例的理解,应该是这样的:

分配确认成功时应运行的单击处理程序,然后分配确认插件

 $('.deleteMe').live('click',function() {
    // Code here for when they click YES on the confirm box.
    // This only executes in 2 scenarios, either the item was clicked
    //   and the confirm plugin was not active, or it was active and
    //   the user selected Yes.
 });

 function updateConfirms() {
    $('.deleteMe').confirm({
      msg:'Confirm Action!<br />',
      stopAfter:'ok',
      eventType:'click',
      timeout:5000,
      buttons: { ok:'Yes', cancel:'No', separator:' - '}
    });
 }

 updateConfirms();
$('.deleteMe').live('click',function()){
//当他们在“确认”框中单击“是”时,在此处进行编码。
//这仅在两种情况下执行,或者单击了该项
//确认插件未激活,或者它处于激活状态,并且
//用户选择“是”。
});
函数updateConfirms(){
$('.deleteMe')。确认({
消息:“确认操作!
”, 停止后:'好', 事件类型:'单击', 超时:5000, 按钮:{确定:'Yes',取消:'No',分隔符:'-'} }); } 更新公司();
由于您提到的动态特性,您需要在添加需要确认的新元素后调用updateConfirms()

编辑:让我们尝试不使用Live,并在任何添加后刷新单击处理程序和确认:

 function updateConfirms() {
   $('.deleteMe').click(function() {
    // Code here for when they click YES on the confirm box.
    // This only executes in 2 scenarios, either the item was clicked
    //   and the confirm plugin was not active, or it was active and
    //   the user selected Yes.
   });

   $('.deleteMe').confirm({
     msg:'Confirm Action!<br />',
     stopAfter:'ok',
     eventType:'click',
     timeout:5000,
     buttons: { ok:'Yes', cancel:'No', separator:' - '}
   });
 }

 updateConfirms();
函数updateConfirms(){
$('.deleteMe')。单击(函数(){
//当他们在“确认”框中单击“是”时,在此处进行编码。
//这仅在两种情况下执行,或者单击了该项
//确认插件未激活,或者它处于激活状态,并且
//用户选择“是”。
});
$('.deleteMe')。确认({
消息:“确认操作!
”, 停止后:'好', 事件类型:'单击', 超时:5000, 按钮:{确定:'Yes',取消:'No',分隔符:'-'} }); } 更新公司();
您好,我尝试了您所说的内容,但不幸的是,它似乎与delete方法没有关联。我正在添加被调用的元素,然后按照您的指示运行函数,但是它似乎没有将确认处理程序添加到.deleteMe元素。只要我单击deleteMe元素,它就会直接进入警报hello呼叫,而不是确认。@John好的,可能是“活动”部分导致了问题。我将发布一个快速修改。@John尝试我刚刚发布的第二种方法,并让我知道。无论你是谁,你都是一个传奇。