RJS prototype removeClassName


#1

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


#2

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’


#3

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’