沒有方法,我有這個功能在我的JS文件
(function($) {
$.fn.foobar = function() {
// some code
};
})(jQuery);
,當我撥打以下
jQuery(function() {
$.getScript("http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js");
$.getScript("http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js");
jQuery('object').foobar();
});
它給了我下面的
Uncaught TypeError: Object [object Object] has no method 'foobar'
我正在試試Rails文件(* .js.erb)
檢查您的js的執行順序。 – xdazz
你能展示一些你的「//一些代碼」嗎?可能有可能你有一個語法錯誤,所以該函數沒有得到正確聲明 – Alex
編輯,告訴你我怎麼在fuxing之前調用jquery –