【问题标题】:Rails 3 and RJSRails 3 和 RJS
【发布时间】:2011-01-27 05:09:36
【问题描述】:

我使用的是 rails 3.0.0.beta

有没有新的写RJS的语法,这里是一个例子

  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

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3 rjs


    【解决方案1】:

    不确定 rails 3 irt rjs 的任何语法更改,但我建议继续关注 railscasts.com - 他一直在发布有关 rails 3 的所有新功能的视频,以及是否有关于如何渲染/处理 js 的更新我相信他会为此制作一集。

    【讨论】:

      【解决方案2】:

      这里是截屏视频http://railscasts.com/episodes/205-unobtrusive-javascript

      2011 年 4 月更新:正在为 Rails 3.1 提取 RJS

      当 Rails 3.1 出来时,prototype-rails 将成为一个宝石

      使用 RJS 的应用程序在使用 3.1 版本之前的 Rails master 时必须将此行添加到其 Gemfile:

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

      更多关于 ruby​​ on rails 的信息可以在 this article 找到

      prototype-rails on github

      【讨论】:

      • 该 gem 可以与 jquery-ujs 一起使用以恢复对 RJS jquery 的支持吗?
      • 带有 JQuery 的 RJS 模板怎么样?
      • Jrails 完成了这项工作,但该项目的最后一次更新是在 2009 年 10 月 21 日完成的!!! mirror.ozdiy.com/assets/b8/…
      猜你喜欢
      • 1970-01-01
      • 2011-06-01
      • 1970-01-01
      • 2010-10-02
      • 1970-01-01
      • 2012-04-26
      • 2011-11-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多