# Using window.onload commands the 'rails way'

**URL:** <https://www.ruby-forum.com/t/using-window-onload-commands-the-rails-way/82945>\
**Category:** Rails\
**Created:** [January 22, 2007, 4:51pm UTC](https://www.ruby-forum.com/t/using-window-onload-commands-the-rails-way/82945 "2007-01-22T16:51:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4bbf92/32.png) [@michael](https://www.ruby-forum.com/u/michael)\
**Post date:** [January 22, 2007, 4:51pm UTC](https://www.ruby-forum.com/t/using-window-onload-commands-the-rails-way/82945/1 "2007-01-22T16:51:40Z")

</div>

I’m trying to integrate niftycube  
([Nifty Corners Cube - freedom to round](http://www.html.it/articoli/niftycube/index.html)) into my rails app.  
It however requires that you specify window.onload commands for each of  
the rounded areas which you wish to use.

Given that my app is setup using layouts, I was wondering if anyone had  
any good ideas of how to incorporate this into the application.

One approach that comes to mind is to do \<%= javascript\_tag  
“window.onload=function() {Nifty(‘div#box’,‘big’);}” %\> inline in the  
view, but this doesn’t seem to work if there are multiple divs you want  
rounded in one view, (the onload function gets over ridden). I guess  
you could also add an element to an array every time you want something  
rounded but this seems cumbersome.

Any ideas?
