我有此鏈接:爲什麼我的應用程序告訴我我的方法未定義?
<%= link_to_function "remove", "remove_fields(this)"%>
其輸出這個網站:
<a href="#" onclick="remove_fields(this); return false;">remove</a>
,我有這個jQuery功能:
function remove_fields(link){
$(link).prev("input[type=hidden]").val("1");
$(link).closest(".fields").hide();
}
但是當我點擊該鏈接後,我得到此錯誤:
Uncaught ReferenceError: remove_fields is not defined
這是爲什麼?如何解決?
何處以及如何被定義的功能? – deceze 2011-05-23 07:20:29
在我的application.js文件中 – 2011-05-23 07:22:16
它是在jQuery就緒語句之下嗎?嘗試從那裏移動它到公共範圍 – metaforce 2011-05-23 07:22:27