2009年11月22日 星期日

rjs page call

RJS Page.call
Passing objects from Rails RJS to a javascript function call without quoting the values?
http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html

 
#有些時候page.call paramter work 不是很正常
page.call "get_details", "info-id", "message","{phone:5487895, mobile:9888565875}"
page.call("buildYUITreeView", "project_tree", @current_project.get_directory_contents(@current_project.local_path, 0))
#可以用這樣的方式去取代
page << "get_details('info-id','message','{phone:5487895, mobile:9888565875}')"
page << "buildUYITreeView('project_tree', #{@current_project.get_directory_contents(@current_project.local_path, 0))})"


respond_to do |format|
format.js {render(:update) { |page| page << 'alert("Wrong Nick");'}}
end


update_page do |page|
page.insert_html :bottom, 'list', "
  • #{@item.name}
  • "
    page.visual_effect :highlight, 'list'
    page.hide 'status-indicator', 'cancel-link'
    end

    沒有留言: