Forum: Ruby on Rails RJS prototype removeClassName

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2007-02-09 12:49
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
Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2007-02-09 14:45
Kad Kerforn 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'
A2c85dc5ee81b12e3cc0a6522e8d079d?d=identicon&s=25 Chris Hall (au5lander)
on 2007-02-09 14:52
(Received via mailing list)
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'
This topic is locked and can not be replied to.