I’ve got a js object on my page named appts which has a method render().
My problem is when i use RJS to call “appts.render()”. it doesn’t do
anything at all. There are no errors also displayed.
I’ve got a js object on my page named appts which has a method render().
My problem is when i use RJS to call “appts.render()”. it doesn’t do
anything at all. There are no errors also displayed.
here is my rjs code:
page << “appts.render(‘BG’,0);”
Here is the problem resolution sequence:
Turn on browser’s javascript debugging (e.g. in Firefox take a look
at
javascript console or install a powerful FireBug extension). You’ll see
all
the javascript errors.
Examine javascript code that is generated by RJS template. Make sure
that
it contains no errors (you can view RJS response in FireBug’s console).
Make sure that the RJS response is properly evaled. E.g. in
Ajax.Request
there should be evalScripts options set to true.
Make sure that you don’t overwrite RJS response’s content type and it
is
equal to “text/javascript” (you can view RJS response in FireBug’s
console).
I’ve got a js object on my page named appts which has a method render().
My problem is when i use RJS to call “appts.render()”. it doesn’t do
anything at all. There are no errors also displayed.
here is my rjs code:
page << “appts.render(‘BG’,0);”
Here is the problem resolution sequence:
Turn on browser’s javascript debugging (e.g. in Firefox take a look
at
javascript console or install a powerful FireBug extension). You’ll see
all
the javascript errors.
Examine javascript code that is generated by RJS template. Make sure
that
it contains no errors (you can view RJS response in FireBug’s console).
Make sure that the RJS response is properly evaled. E.g. in
Ajax.Request
there should be evalScripts options set to true.
Make sure that you don’t overwrite RJS response’s content type and it
is
equal to “text/javascript” (you can view RJS response in FireBug’s
console).
Hope that helps
I had already 1-4 covered. Here is the actual code that was spit on the
debugger:
There is no exception when this gets executed but the object doesn’t do
anything. when i do --> page << “alert(appts);”, i get this --> [object
Object]
Try putting alert inside render() method to see if it actually get
execute.
If it is, then the problem is in your code, otherwise
Try exploring all “appts”'s object properties:
function inspect(o) {
var result = “Object “+o+” {\n”;
for(attr in o) {
result += “”+attr+" = “+o[attr]+”\n";
}
result += “}\n”;
return result;
}
Put this function into some place from where it could be loaded before
RJS
call (e.g. RAILS_ROOT/public/javascripts/application.js if you use
javascript_include_tag :defaults) and then in RJS do "page
<< “alert(inspect(appts));”
Try putting alert inside render() method to see if it actually get
execute.
If it is, then the problem is in your code, otherwise
Try exploring all “appts”'s object properties:
function inspect(o) {
var result = “Object “+o+” {\n”;
for(attr in o) {
result += “”+attr+" = “+o[attr]+”\n";
}
result += “}\n”;
return result;
}
Put this function into some place from where it could be loaded before
RJS
call (e.g. RAILS_ROOT/public/javascripts/application.js if you use
javascript_include_tag :defaults) and then in RJS do "page
<< “alert(inspect(appts));”
It might be that you’ve got wrong object.
Thanks for the info. I think there’s something wrong with the js object
or with RJS itself with complex objects. Its a pretty complex one which
has multiple objects inside it.
appts contains an array of appointment objects. each appointment object
also contains a hash of measurement objects.