Lukas Z's Private Blog

(mostly about programming)

Javascript Popup Windows With Rails

Javascript popups still have their uses. Here is a tiny snippet that one can use to create Javascript popup-windows in a Ruby on Rails application in an elegant fashion.

In your application.js (or whatever .js-file you prefer) include this:

$('a[data-popup]').live('click', function(e) { $(this).attr('href'), "Popup", "height=600, width=600" ); 

Then, in your views add the data-popup-attribute to the link_to-helper:

<%= link_to( 'Open Popup-Window', popup_window_path, 'data-popup' => true ) %>

This is basically taken from [here]( “”). I have just added two extra parameters to

P.S.: You can follow me on Twitter.