rjs

Javascript Include Tag Best Practice in a Rails Application

≯℡__Kan透↙ 提交于 2019-11-27 09:09:26
问题 Say I need to call a javascript file in the <head> of an ERb template. My instinct is to do the usual: <head> <%= javascript_include_tag :defaults %> <!-- For example --> </head> in my application's layout. The problem of course becoming that these javascript files are loaded into every page in my application, regardless of whether or not they are needed for the page being viewed. So what I'm wondering is if there's a good way of loading a javascript into the the headers of, for example, all

Rails 3 and RJS

本小妞迷上赌 提交于 2019-11-26 22:59:37
问题 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 回答1: here is the screencast http://railscasts.com/episodes/205-unobtrusive-javascript UPDATE April 2011: RJS is being