Topic: accessing this.parentNode in RJS

Does anyone know how I can do this Javascript command with RJS?

this.parentNode.className = 'selsec';

This is what my AJAX call looks like which will invoke load_chart.rjs

<%= link_to_remote "Ajax Magic" , :url => {:controller => "chart", :action => "load_chart" } %>

How exactly would access "this" in an RJS template?


Last edited by patelc75 (2007-09-04 08:58:19)

Re: accessing this.parentNode in RJS

you can't really... the Javascript returned by the AJAX Call is not really evaluated in the context of a specific element, at least that's what i think but i could be wrong wink

However, i guess you replace some div content and then want to set the class of the parent to "selsec" ? This *might* work.

page.replace_html "some_div" "blablabla"
page << "$($('some_div').parentnode).addClassName('selsec')"

Last edited by Duplex (2007-09-04 09:15:21)