Run JavaScript function onLoad in a Rails view? -


my rails view looks (it partial):

=javascript_include_tag :defaults  #scroller  -@other_images.each |img|   .thumbnail_wrapper     .thumbnail_image       =image_tag img.image.url(:thumbnail), :class => 'button', :onclick => "replaceimg(#{img.id});",  :onload => "setlastid(#{ @other_images[0].id });" 

i want call function setlastid(#{ @other_images[0].id }); once, when whole view loads. however, couldn't figure out how... place put worked. it's been called each time within loop... help!!

this example want dynamically generate javascript in partial, since ruby variables required. long these sorts of calls short, i'm fine it.

=javascript_include_tag :defaults  #scroller  -@other_images.each |img|   .thumbnail_wrapper     .thumbnail_image       =image_tag img.image.url(:thumbnail), :class => 'button', :onclick => "replaceimg(#{img.id});"  :javascript   setlastid(#{@other_images[0].id}); 

Comments

Popular posts from this blog

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

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

iphone - How would you achieve a LED Scrolling effect? -