Is DOM not being loaded ?
Posted
by
Daniel
on Stack Overflow
See other posts from Stack Overflow
or by Daniel
Published on 2011-01-13T14:49:52Z
Indexed on
2011/01/13
14:53 UTC
Read the original article
Hit count: 233
JavaScript
|ruby-on-rails3
I went through episode 88 (Dynamic menus) of the railscasts and when I try to load my *js.erb file in the browser shows me that my fetched data from the controller is getting there
Controller
def dynamic_departments
@departments = Department.all
end
localhost:3000/javascripts/dynamic_departments.js
var departments = new Array();
departments.push(new Array(1,'????',1));
departments.push(new Array(2,'???-???',2));
function facultySelected(){
faculty_id = $('falculty_id').getValue();
options = $('department_id').options;
options.length = 1;
departments.each(function(department){
if(department[0] == faculty_id){
options[options.length] = new Option(department[1],department[2])
}
});
if(options.length == 1){
$('department_field').hide();
} else {
$('department_field').show();
}
}
document.observe('dom:loaded', function(){
alert("DOM loaded");
//$('department_field').hide();
//$('faculty_id').observe('change',facultySelected);
});
My routes.rb has the match ':controller/:action.:format' Still...after the page's loaded and I change the value of my collection_select or select nothing happens.What am I missing?
*I called the 'alert' and commented the rest to test it....still nothing.
© Stack Overflow or respective owner