License

Are you web pages composed of many rails partials? Wouldn't it be cool if the partials can be told to refresh itself?

This gem introduces a jquery method .reload(), when executed, pulls a fresh copy of the partial and renders it inside the div.

demo

This, combined with Server Generated Javacript Responses gives your app SPA (Single Page App) like benefits, without the added complexity of a client-side JavaScript framework

To install, add this to your Gemfile

gem "piper"

After that, specify the use of the jquery and best in place javascripts in your application.js

//= require piper

To make use of this gem, use <%= render_cell %> instead of <%= render partial: This wraps the rendered partial in a div, and that div gets locals metadata embeded in it as a data-piper attribute.

render

render_cell also expects an addditional argument, called container, which serves as the jquery selector, so if you pass container: 'foo' your resulting javascript command becomes $('.foo').reload()

Also remember to pass locals literally like this

locals: '{ var1: "abc", var2: Blog.first }'  # single quotes!

This means we're "passing by reference".

You will also need to add this route

get '/partial' => 'piper/partials#show'

Prereqs

Assumes jquery-ui has been installed in the rails app.

Authors, License and Stuff

MIT license. Many thanks to best_in_place project on github. I borrowed quite a few ideas from it.