SPAkit: A SPA Rails plugin
SPAkit’s idea comes form registrano.com and Massage plugin. It’s a rails plugin that can transform existed website to single page application easily. Only change to use SPAkit helper and need not modify controller code, then your hyperlink and form submit will send Ajax request and update page.
Spakit is hosted at github. Please download tarball and put in your vender/plugins/spakit
After that, please create a layout for SPAkit. A simple example is:
# /view/layouts/spakit.rhtml
<%= flash[:notice] %>
<%= yield %>
Now you can use SPAkit helpers, we have spakit_link_to, spakit_form_for and spakit_form_tag. Some examples are:
spakit_link_to 'new person', :url => new_person_path
spakit_form_for @person, :url => people_path
When click or submit, Spakit will send Ajax request(i.e. prototype’s Ajax.Updater ) and update #content block by returned HTML.
If you want to support Histroy Bookmarks of Ajax,we recommend using Really Simple History(RSH) library to handle the Browser forward/back issue. One example is in plugin README document and it’s depend on jquery library(thanks for writing prototype version). The real sample just like http://registrano.com.
PS. This post has Chinese version at ihower’s blog.
1 Comment
Jump to comment form | comments rss [?] | trackback uri [?]