Author:: Wen-Tien Chang(mailto:ihower@gmail.com), hlb(mailto:hlb@handlino.com) Copyright:: Copyright (c) 2007 Handlino Inc. License:: Distributed under the New BSD License == Description == Spakit is a plugin that makes it very easy to turn your Rails App Into a "single page application" (SPA). To enable SPA, simply install the plug-in, create a spakit layout and use Spakit helper. Don't need modify any model/controller code... ;) Spakit will send xhr request(i.e. prototype's Ajax.Updater ) with ?layout=spakit, and controller return HTML with spakit layout. Note that spakit_form_for not support file upload submit. By the way, Message plugin is another SPA plugin,using different approach. == Usage == For now, Spakit provide three helper: * spakit_link_to, just like remote_link_to * spakit_form_for, just like form_for, but you must specify :url * spakit_form_tag, just like form_tag by default spakit will replace HTML element called #content. == Layout code example == You should write flash message here because we often place that in application layout. # /view/layouts/spakit.rhtml
<%= flash[:notice] %>
<%= yield %> == History Bookmarks == We recommend Really Simple History(RSH) library to handle browser forward/back. Example code: # environment.rb module SpakitHelper @@spa_options = { :update => 'content-region', :loading => 'SPA.loading', :complete => 'SPA.complete' } end # application.js # We use jquery syntax, you can use prototype to define your function. var $j = jQuery.noConflict(); (function($) { SPA = { currentHash: null, currentLocation: null, init: function() { if ( $('#waiting-message').length == 0 ) { $('