RJS & ReferenceError

Hello,

is there a way to suppress rjs error messages, because i am trying to
check
if some variable is present, with (variable == undefined), but rjs stops
processing and throws out error, because there is >>reference error<<.
Whatever, this is javascript, you cannot have reference error in
javascript…

BTW: i know i could just create a javascript file, and assign undefined
values to variables, but that would kinda suck.

Thanks for any suggestions.

Aleksander PejčiÄ? wrote:

Hello,

is there a way to suppress rjs error messages, because i am trying to
check
if some variable is present, with (variable == undefined), but rjs stops
processing and throws out error, because there is >>reference error<<.
Whatever, this is javascript, you cannot have reference error in
javascript…

This isn’t rjs stopping processing, it’s your browser throwing the
exception while evaluating the javascript (which just happens to be
created via rjs).
see http://www.irt.org/script/778.htm for testing for the presence of a
variable.

Fred

You must be mistaken…

i have this code:
if(timer == undefined)
timer = setTimeout(“effect = new fx.Opacity($(‘login_message’),
{duration: 2000, onComplete: function() { timer =
undefined;}}).toggle();”, 2000);

You can probably see what i am trying to accomplish.

And it work if i use it like a regular javascript, which means putting
it in external .js file or “inlineing” it html file, but when i use
this inside rjs file with page << “…” directive, i get rjs warnig
about reference error.

some more fun:

page << " alert(typeof timer); ", messaged that timer is undefined, and
right after i pressed ok, a new alert popped up whining about rjs
reference error

Update: (typeof timer == ‘undefined’) worked

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs