Rails en de kracht van RJS Templates

Post on 24-Apr-2015

2.575 views 1 download

description

Peter Dierx' slide's of his presentation at the RubyenRails 2007 conf in Amsterdam

Transcript of Rails en de kracht van RJS Templates

RJS Templatesr a i l s e n d e k r a c h t v a n

RJS Templates

RJS Templatesr a i l s e n d e k r a c h t v a n

P e t e r D i e r x

RJS Templatesr a i l s e n d e k r a c h t v a n

P e t e r D i e r x

W e l k o m

class Railstation < ActiveRecord::Base

heeft_een_domein :www.railstation.eu

is_eigendom_van :peter_dierx

geeft_trainingen :rails_starter, :rjs

vanuit_een_cool :wijnproeflokaal

end

RJS Templatesr a i l s e n d e k r a c h t v a n

Wat zijn RJS Templates?

RJS Templatesr a i l s e n d e k r a c h t v a n

Remote JavaScript

Met een .rjs extensie

In Ruby

RJS Templatesr a i l s e n d e k r a c h t v a n

toon_verberg.rjs

page.toggle ‘help_scherm’

RJS Templatesr a i l s e n d e k r a c h t v a n

controller

render :update do |page| page.toggle ‘help_scherm’end

RJS Templatesr a i l s e n d e k r a c h t v a n

Waarom RJS?

RJS Templatesr a i l s e n d e k r a c h t v a n

Clean en simpel•om mee te starten

•slagroom op de taart

•genoeg opties

•standaard in Rails

RJS Templatesr a i l s e n d e k r a c h t v a n

Hoe werkt RJS?

RJS Templatesr a i l s e n d e k r a c h t v a n

Ruby on Rails

RJS Templatesr a i l s e n d e k r a c h t v a n

RJS Templatesr a i l s e n d e k r a c h t v a n

RJS Templatesr a i l s e n d e k r a c h t v a n

Naadloze integratie

‘out of the box’

RJS Templatesr a i l s e n d e k r a c h t v a n

Dat is de kracht!!

RJS Templatesr a i l s e n d e k r a c h t v a n

Hoe was het voor RJS?

RJS Templatesr a i l s e n d e k r a c h t v a n

<%= link_to_remote ‘Klik Hier’, :update => ‘bericht_div’, :url => { :action => ‘bericht’ } %>

RJS Templatesr a i l s e n d e k r a c h t v a n

<%= javascript_include_tag :defaults %>

prototype, effects, dragdrop, controls

<%= javascript_include_tag ‘prototype’ %>

RJS Templatesr a i l s e n d e k r a c h t v a n

Hoe werkt het met RJS?

RJS Templatesr a i l s e n d e k r a c h t v a n

<%= link_to_remote ‘Klik Hier’, :url => { :action => ‘bericht’ } %>

RJS Templatesr a i l s e n d e k r a c h t v a n

<%= link_to_remote ‘Klik Hier’, :update => ‘bericht_div’, :url => { :action => ‘bericht’ } %>

RJS Templatesr a i l s e n d e k r a c h t v a n

<%= link_to_remote ‘Klik Hier’, :update => ‘bericht_div’, :url => { :action => ‘bericht’ } %>

:update genereert een Ajax.Updater Object

We willen echter een Ajax.Request Object

RJS Templatesr a i l s e n d e k r a c h t v a n

Demo