2011-08-01 25 views
0

Error: jQuery(domChunk).live is not a function Source File: http:///wp-includes/js/thickbox/thickbox.js?ver=3.1-20110528 Line: 26錯誤的jQuery(domChunk).live不是一個函數

這是函數:

//add thickbox to href & area elements that have a class of .thickbox 
function tb_init(domChunk){ 
    jQuery(domChunk).live('click', tb_click); 
} 

使用jQuery 1.6.1版本。 有沒有辦法解決這個錯誤?

+1

聽起來像你傳遞一個「domChunk」這不是一個「domChunk」 – Raynos

+0

的「domChunk」傳遞是根據螢火蟲「a.thickbox,area.thickbox,input.thickbox」。 – JohnnyBizzle

+0

它顯示爲版本1.2.6 似乎很舊。 – JohnnyBizzle

回答

0

要解決thickbox.js與下面的一個替代tb_init()函數 - 這將支持的jQuery的所有版本!它檢查on()函數是否存在,如果不存在,它將回退到live()。

function tb_init(domChunk){ 
    if($.isFunction($domChunk).on)) 
    { 
     $(domChunk).on('click', domChunk, function(){ 
      var t = this.title || this.name || null; 
      var a = this.href || this.alt; 
      var g = this.rel || false; 
      tb_show(t,a,g); 
      this.blur(); 
      return false; 
     }); 
    } 
    else 
    { 
     $(domChunk).live('click', function(){ 
      var t = this.title || this.name || null; 
      var a = this.href || this.alt; 
      var g = this.rel || false; 
      tb_show(t,a,g); 
      this.blur(); 
      return false; 
     }); 
    } 
} 
相關問題