javascript - How do you refresh js variables after loading a new partial in RoR? -


in javascript file, pull off rails variable view:

this.main_id = <%= images[0].id %>; 

then use ajax load partial portion of page (the view in question):

var url = '/images/thumbnails_newest/'+ this.main_id; new ajax.updater(this.scroller, url); 

now js variable this.main_id has changed... don't know how access rails variable in partial... update value.

this.main_id = this.main_id in partial.

is there way this? thanks.

add these line @ end of partials

<script> this.main_id=<%=images[0].id%>; </script>

or define js method can set value of this.main_id , takes 1 paramerter image_id , call @ end of partial assume js method name set_main_id call @ of partial code below

<script> set_main_id(<%=images[0].id%>); </script>

actually code in script tag run on client side, client have previous content when new content come js update previous one. hope you.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -