在我的js文件中,我这样写
document.observe("dom:loaded", function() {
add();
});
但显示错误TypeError:document.observe不是一个函数
我正在使用Rails 3&jquery-ui-1.10.0
谁能告诉我为什么我会这样?
提前致谢
当Rails 3使用jquery时,您将在原型中编写代码。这可能会在这里造成问题。
因此,请尝试在jquery中转换您的代码。您的代码可能看起来像。
$( document ).ready(function() {
// Run code
});
但请考虑以下内容,并根据需要进行更改
$(window).load(function(){
// Run code ##It will run the js after the whole page is loaded.
});
$(document).ready(function(){
// Run code ##It will run the js just after the loading of DOM.
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句