English 中文(简体)
j Query.off()不是取消具有约束力的限制。
原标题:jQuery.off() is not removing binding

For some reason jQuery.off( click ) doesn t seem to be working here. When the Yes button is clicked in the model another model just pops up. What am I doing wrong?

法典:

$(function(){

  //If there are warnings on the page bind alert
  if ($( .renewal-warning ).length > 0){

    (function (){

      $( #signRentalContainer ).on( click ,  .renewal-warning , function(e){

        var buttonHandle = this;

        //Prevent submission
        e.preventDefault();

        //Show warning model
        $.modal({
          content: $( #renewalWarning ).html(),
          title: "Order Renewal Warning",
          buttons: {
             Yes : function(win) { $(buttonHandle).off( click ).click(); },
             No : function(win) { win.closeModal(); }
          },
          maxWidth: 250,
          closeButton: false
        });
      });
    })();
  }
});
最佳回答

确实,你需要提供同样的要素以及同样的选择。

$( #signRentalContainer ).off( click ,  .renewal-warning );

在<代码>.on() 手递中,this是被点击的<代码>.renewal-warning 要素,而不是#signRentalContainer要素。


如果这些<代码>中有若干项内容,则重新警告,而且你只想在某一时间加以区别,最简单的方式是改变其类别,使其不再符合选择。

$(this).removeClass( renewal-warning )
       .addClass( renewal-warning-disabled );
问题回答

由于<代码>这一指的是处理功能的背景,而不是功能本身。

在请打电话<代码>off时,请查阅:

$('one”).off("click”, #signRentalContainer , buttonHandle;

BTW,我们在此直接使用<条码>unbind的任何理由?

$(“#signRentalContainer”).unbind(“click”);





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签