RJS prototype removeClassName

How can I test fi the element has the property before removing it

I tested
page[‘mypropCity’].removeClassName(‘wrong’) if
page[‘mypropCity’].hasClassName(‘wrong’)

but it doesn’t work…

thanks

kad

Kad K. wrote:

How can I test fi the element has the property before removing it

I tested
page[‘mypropCity’].removeClassName(‘wrong’) if
page[‘mypropCity’].hasClassName(‘wrong’)

but it doesn’t work…

thanks

kad

Got it : need to write plain JS in my page to perform this check…
as JS is not aware of the Rails ‘if’

removeClassName and hasClassName are not rails prototype helper
methods, so that’s why it’s not working.

also, you don’t need to check if the classname exists, just remove it.
if it exists it will be removed.

page.call ‘Element.removeClassName’, ‘element_id’, ‘classname’