WindowRails (for jQuery)

WindowRails is a plugin for Rails that provides easy to use AJAXy windows. It is based completely on jQueryUI with helpers for Rails to make it easy to use from a Rails app.

WindowRails is now happily compatible with Rails 2 and Rails 3.

Requirements

  • jQuery

  • jQuery-UI with Dialog widget enabled

Installation

rake window_rails:install

Basic examples to get you started

Remote calls to create a window

# view
<%= link_to_remote('Link', :url => my_route_path) %>

# controller 

def action
  respond_to do |format|
    format.html
    format.js do
      render :update do |page|
        page.open_window(
          {:partial => 'action_partial'},
          :width => 400,
          :height => 500,
          :title => 'My Window',
          :window => 'unique_window_name'
        )
      end
    end
  end
end

Linking to a window

Load an entire HTML page into an IFrame
<%= link_to_window('Link', :iframe => {:controller => :my_controller, :action => :my_action}, :window => 'some_name') %>

With this approach the contents of the HTML respond to block will be loaded into the window

Load a partial page directly into the DOM within the window
<%= link_to_window('Link', :url => {:controller => :my_controller, :action => :my_action}, :width => 400, :height => 300, :window => 'some_name') %>

With this approach the content returned from the JS respond to block will be loaded into the window. No need for requesting the window to be created from the controller.

Window Interactions

Opening a window via AJAX

def open_my_window
  respond_to do |format|
    format.html
    format.js do
      render :update do |page|
        page.open_window({:partial => 'my_partial'}, :width => 400, :height => 200, :window => 'my_window')
      end
    end
  end
end

Updating a window via AJAX

def update_my_window
  respond_to do |format|
    format.html
    format.js do
      render :update do |page|
        page.update_window({:partial => 'new_partial'}, :window => 'my_window')
      end
    end
  end
end

Closing a window via AJAX

def close_my_window
  respond_to do |format|
    format.html
    format.js do
      render :update do |page|
        page.close_window(:window => 'my_window')
      end
    end
  end
end

Documentation

WindowRails documentation

Bugs/Features

Issues

License

  • WindowRails is released under an MIT license