in my js file i wrote like this
document.observe("dom:loaded", function() {
add();
});
but it show error TypeError: document.observe is not a function
I am using rails 3 & jquery-ui-1.10.0
can any one tell me why i am getting like this ?
Thanks in advance
in my js file i wrote like this
document.observe("dom:loaded", function() {
add();
});
but it show error TypeError: document.observe is not a function
I am using rails 3 & jquery-ui-1.10.0
can any one tell me why i am getting like this ?
Thanks in advance
Share Improve this question asked Sep 23, 2014 at 10:33 Siva KBSiva KB 3571 gold badge6 silver badges19 bronze badges 2- Possible copy of stackoverflow./questions/1907702/… – Nitin Commented Sep 23, 2014 at 10:36
- it also show the same error TypeError: $(...).observe is not a function – Siva KB Commented Sep 23, 2014 at 10:46
1 Answer
Reset to default 5As rails 3 uses jquery and you are writting code in prototype. That might creating issue here.
So try convert your code in jquery. Your code might look like.
$( document ).ready(function() {
// Run code
});
But consider below and make your changes as per your need
$(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.
});