簡體   English   中英

帶有jQuery Rails的Colorbox的.live()錯誤

[英].live() error for colorbox with jquery rails

我用過rails 4.0.0

也是jquery rails 3.0.4

jquery.colorbox.js v 1.3.19

我有一個鏈接<%= link_to "Upload Image", edit_seller_banner_users_path, class: "photobox" %>

在js中

$('.photobox').click(function(e){
  $(this).colorbox();

  });

它向我顯示錯誤為TypeError: $(...).live is not a function在Firebug中TypeError: $(...).live is not a function ,並且鏈接重定向未打開顏色盒... Plz幫助。

從jQuery 1.7開始不推薦使用live() ,並在1.9中將​​其從源代碼中完全刪除。

您有3個選擇:

  • 如果您有依賴於此的第三方插件,請嘗試migration插件
  • 重構代碼以將on()與委托參數一起使用。
  • 堅持使用舊版本的jQuery(<1.9)

這是因為

由於。 live不推薦使用jQuery1.7。

嘗試遷移/升級。

http://api.jquery.com/category/deprecated/deprecated-1.7/

jQuery的live()已棄用。 我現在要用什么?

嘗試在jquery之后在應用程序中使用jQuery-migrate.js。

請檢查http://blog.jquery.com/2013/05/08/jquery-migrate-1-2-1-released/並鏈接http://code.jquery.com/jquery-migrate-1.2.1 .js文件

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM