5

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
denisjacquemin
  • 7,414
  • 10
  • 55
  • 72

2 Answers2

11

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

user229044
  • 232,980
  • 40
  • 330
  • 338
denisjacquemin
  • 7,414
  • 10
  • 55
  • 72
  • can that gem be use with jquery-ujs to get RJS jquery support back? –  May 09 '11 at 09:15
  • What about RJS templates with JQuery? –  May 22 '11 at 16:15
  • Jrails do the job, but the last update on the project was done on October 21, 2009!!! http://mirror.ozdiy.com/assets/b8/2f96a12bc919b37e09d303b86ea1b9_1251811910.html – denisjacquemin May 23 '11 at 10:50
0

not sure on any syntax changes for rails 3 irt rjs but i recommend following along over at railscasts.com - he's been posting videos of all the new features of rails 3 and if there are any updates on how to render/handle js i'm sure he'll do an episode on it.

BandsOnABudget
  • 3,966
  • 2
  • 17
  • 19