Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 and RJS

I use the rails 3.0.0.beta

Is there any new syntax to write RJS, here is an example

  def remote_create
    @photo = Photo.new(params[:photo])

    respond_to do |format|
      if @photo.save
        # add @photo's thumbnail to last import tag
        format.js {
          render :update do |page|
            page.insert_html :bottom, 'polaroids' , :partial    => 'polaroid', :locals => {:photo => @photo}
          end 
        }
      else
        #...
      end
    end
  end
like image 214
denisjacquemin Avatar asked Mar 13 '10 17:03

denisjacquemin


1 Answers

here is the screencast http://railscasts.com/episodes/205-unobtrusive-javascript

UPDATE April 2011: RJS is being extracted for Rails 3.1

prototype-rails is going to be a gem when Rails 3.1 is out

Applications using RJS have to add this line to their Gemfile while working against Rails master before the 3.1 release:

gem 'prototype-rails', :git => 'git://github.com/rails/prototype-rails.git'

more info on ruby on rails's could be found in this article

prototype-rails on github

like image 153
denisjacquemin Avatar answered Sep 20 '22 22:09

denisjacquemin