Tag: rjs

将表单对象传递给从ajax请求呈现的部分对象

我有一个带有一些嵌套属性模型的事件表单。 从选择框中选择客户端后,将呈现其他模型。 观察者观察并调用控制器动作,该动作呈现包含fields_for嵌套模型的部分。 我遇到的问题是我无法将事件’form’块传递给新渲染的部分 – 至少我无法弄清楚如何… 下面的代码引发了错误:“错误的参数数量(0表示1)”。 任何帮助或建议表示赞赏。 如下所述,如果您可以为此方案提供示例,我也愿意使用不引人注目的JavaScript重新实现它。 活动表格: event_client_id %> {:action => ‘client_questions’}, :with => “‘client_id=’ + encodeURIComponent(value)+’&event_id=’+#{@event.id} %> 事件控制器 def client_questions @event = Event.find(params[:event_id]) @client = Client.find(params[:client_id]) @client_questions = @client.questions.active respond_to do |format| format.js { render :update do |page| page[:client_questions].replace_html :partial => ‘client_questions’, :layout => false end } end end _client_questions.html.erb partial

使用原型动态加载时,gmaps4rails地图未显示

我有一个视图有3个选项卡,每个选项卡代表数据视图(表,地图,图表)。 当我单击选项卡时,如果运行switch_view.js.rjs,它将使视图失明 {:controller => :biogas_calculator, :action => :switch_view, :view => “table”}, :method => :get, :loading => visual_effect(:blind_up, “biomass_configuration”, :duration => 0.5, :queue => ‘front’), :html => {:id => “table_view”, :class => “toggle_map_button”} %> {:controller => :biogas_calculator, :action => :switch_view, :view => “map”}, :method => :get, :loading => visual_effect(:blind_up, “biomass_configuration”, :duration => 0.5, :queue => ‘front’), […]

如何实现这个嵌套的linked_to_function?

在我看来,我希望用户能够浏览产品目录。 层次结构如下: Category Product AdditionalInfoForm 在我的主视图中,我为类别呈现部分: #opContent = render :partial => ‘op_main_categories’ op_main_categories partial定义如下: – @controller.getPortalCategories.each do |c| = link_to_function “#{c.name}”, :class => ‘opCategoryHeaderText’ do |page| – partial = escape_javascript(render :partial => ‘op_secondary_categories’, :locals => { :c => c }) – page << "$('opContent').update(\"#{partial}\")" 当用户单击上面部分中的链接时,产品将通过op_secondary_categories部分呈现: – @controller.getPortalProductsForCategory(c).each do |p| = link_to_function “#{p.name}”, :class => ‘opCategoryHeaderText’ […]

YUI3 Uploader + Rails rjs

我正在尝试将YUI3 Uploader与Rails 2.3.12项目一起使用。 我已经完成了上传后解析响应的工作。 响应是一个RJS文件呈现部分,以更新页面上的元素。 当通过正常的非Flash上​​传运行时,此RJS按预期工作,并且它与SWFUpload插件一样正常工作。 在Firefox中,我收到错误: Error: missing } after property list Source File: http://secure.symt.localhost:3000/training_videos/4/edit Line: 0, Column: 204 Source Code: try { __flash__toXML(YUI.applyTo(“yui_3_4_0_2_1314649381592_1″,”SWF.eventHandler”,[“yuiswfyui_3_4_0_2_1314649381592_14″,({data:”try {\nElement.replace(\”training_video_4_poster_current\”, \”Current poster: logo with spaces.JPG — [delete this file]\”);\nElement.replace(\”ajax-flash-container\”, \”\n\n\n\t\n\t\t\n\t\t\n\t\t\ti\n\t\t\t\n\t\t\t\t\n\t\t\t\t\tFile uploaded.\n\t\t\t\t\n\t\t\t\n\t\t\t \n\t\t\n\t\n\t\n\n\n setDoMessages();\n\n\n\”);\n} catch (e) { alert(‘RJS error:\n\n’ + e.toString()); alert(‘Element.replace(\\”training_video_4_poster_current\\”, \\”Current poster: logo with spaces.JPG — [delete this file]\\”);\nElement.replace(\\”ajax-flash-container\\”, […]

从ajax调用重定向主窗口

我有一个ajax调用控制器来检查身份validation,当没有身份validation时,它会将调用发送到signin控制器,该控制器检查它是否是xhr请求。 如果是,它将包含page.redirect_to的rjs呈现到signin路径,并且主窗口被重定向到signin页面。 这在谷歌浏览器中完美无缺,但在Firefox中失败。 rjs文件中唯一的代码是: page.redirect_to(“http://localhost:3000/signin”) 正如我所说,它在chrome中完美运行但Firefox(v3.6)拒绝重定向主窗口。 有没有人对如何在Firefox中使用它有任何想法?

元素更新时出现RJS错误“对象不支持此属性”

我在控制器中有以下代码。 我根据另一个下拉框中的选择动态填充下拉框。 def update_releases project = Project.find(params[:project_id]) releases = project.releases puts “releases==#{releases}” render :update do |page| page.replace_html ‘releases’, :partial => ‘releases’, :object => releases end 查看代码: -form_tag reports_path(report_type=1),:method => :get, :multipart => true ,:id => “filter” do %table.grid.full %tr %td.grid.full_panels{:style => “width: 20%”} Project: %td.grid.full_panels{:style => “width: 20%”} //= select_tag “projects”,options_from_collection_for_select(projects,”id”,”name”,params[:projects]),{:onchange => “#{remote_function(:url => {:action […]

在Ruby On Rails中使用RJS学习的资源

我尝试在Rails应用程序中学习RJS用法,但我在Web上找不到好的资源。 有一些简单的例子,但不是我需要的大量教程。 如果你知道,请建议任何:) 谢谢 …

更新基于另一个的选择框(Ruby on Rails)

我需要一个更完整的例子来说明如何根据Ruby on Rails中第二个选择框的结果更新选择框。 我已经在这里问了这个问题 。 我已经阅读了该post的反馈意见,但是没有任何运气可以解决这个问题,而且我已经尝试了几个小时。 有谁知道一个更好(更完整)的例子?

RJS:检查现有的页面元素?

我有一个id为“foo”的文本字段,有时存在,有时不存在。 如果存在,我想填写一定的价值。 你是如何通过使用RJS (在Rails 2.2中 )这样做的? 我试过这个并不起作用: if page[:foo] page[:foo].value = “bar” end 我明白了 TypeError:Null如果文本字段不存在,则为Value 。

如何使用render(:update)和replace_html重新加载div?

如何只重新加载页面上的div id? 我只需要重新加载某个div。 在我的控制器中我有 def mycontrolleraction … render(:update) do |page| reload_only_the_div(‘adiv’), :controller => ‘my_controller’ end end 这可能吗?