rjs
demystified
a cheat sheet by amy hoy,
www.slash7.com
loaded pagerailscontroller
here's how it works!
6
Javascript responseis detected, eval()'d—and run.
start
triggered by anything youwant... forms, time, etc.e.g.: create a new post,or update a user's profile,or add a new transaction...RJS templatescan use regularviews &partials to addHTML to thepagethis javascript is whatcreates the changesto the pagethis makes the changes happen!
5
compiled JavaScriptis returned via Ajax
1
your visitorloads a page
2
an ajax requestis made
3
the controllerreceives the requestand does its biz behind the scenes
4
the controllercompiles the RJStemplate it found
if@savedpage["new_expense_form"].reset
page.visual_effect:blind_up,:new_expense
page.insert_html:top,:expenses,:partial=>"expense"
page.replace_html:total,"$#{@total}"
page.delay(1)do
page.visual_effect:highlight,"expense_#{@expense.id}"
endelsepage.alert("Problemsavingexpense:#{@expense.errors.full_messages}")
page.visual_effect:blind_up,:new_expense
end
a s a m p l e . . .
45-minute RJS screencastonly $9!peepcode.com
tip!it?
support Slash7!
The controller compiles this into JS & the response is sent as
Content‐Type:text/javascript
Add a Comment
sagiveleft a comment