Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
RJS-Demistified Amy-Hoy-slash7 1

RJS-Demistified Amy-Hoy-slash7 1

Ratings:

5.0

(1)
|Views: 10 |Likes:
Published by khuonglh

More info:

Published by: khuonglh on Apr 16, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

05/09/2014

pdf

text

original

 
RJS templates are "just" another type of 
 view template
, made specifically for answering  Ajax requests. The code you write in an
.rjstemplate
is based around the page you will bechanging—the page that made the Ajax request(and therefore will be getting the response). Anythin you can do with JavaScript, youcan do with RJS.
rjs
demystified
a cheat sheet by amy hoy,
 www.slash7.com
tip!it?
   S   U   P   P   O   R   T   S   L   A   S   H   7
45-minute screencast video on RJS for only $9see it live! click:www.peepcode.com
 what is this RJS thing anyway?
*
R.J.S.,
acronym
Ruby JavaScript
 A templating tool, built inRuby, to output JavaScript.
synonym
,
amazing
Makes it almost utterly painless to craft sophisticated Ajax responses... with sexy results!
 
RJS techniques
insert new HTML anywhereremove HTMLchange DOM propertiesmove things aroundcreate special effectshide stuff show stuff take over the universe
********
 
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@savedpage["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}" endelsepage.alert("Problemsavingexpense:#{@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

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->