【发布时间】:2022-08-16 10:28:52
【问题描述】:
我想在 Rails 中单击按钮时渲染部分内容。 我有两个控制器
- 字段控制器
- 操作员控制器
当用户单击 index.html.erb 上的显示时,它将显示一个弹出窗口,其中包含 Operator Controller 的 index.html.erb 的内容。
这是我的 Fields Controller 的 index.html.erb 按钮:
<%= link_to \"Link\" ,operators_index_path(:id => field_id, :field_name=>field_name), :remote => true %>这是 Operators Controller 的索引方法:
class OperatorsController < ApplicationController def index @operators = Api::AnalyticsQueryBuilderMetadataService::Operator.show(params[:id]) end end这是我想显示为弹出窗口的 Operator Controller 的 index.html.erb 的内容:
<%if @operators[\'items\'].empty?%> <div class=\"error-handling-page\"> <div class=\"dialog\"> <div> <h1>No Operator Found</h1> </div> </div> </div> <%else%> <table class =\"table\"> <thead> <th class =\"head\">Field Name</th> <th class =\"head\">Name</th> <th class =\"head\">Description</th> </thead> <% @operators[\'items\'].each do |data| %> <% @opId = data[\'operators\'] %> <% @opId.each do |value| %> <tr> <td><%= field_name %></td> <td><%= value[\'mnemonic\']%></td> <td><%= value[\'description\']%></td> </tr> <%end%> <%end%> </tbody> </table> <%end%>怎么做?
标签: jquery ruby-on-rails ajax