[英]How to call multiple controller actions into the single page tabs in ruby on rails
I have three models, controllers
and views
. 我有三种
models, controllers
和views
。
1. package
2. source
3. measure
Everything has separate forms
. 一切都有不同的
forms
。 I created a controller
and view
called scenario
and created three tabs(Package, Source and Measure)
in the scenario
page. 我创建了一个
controller
和一个名为“ scenario
view
tabs(Package, Source and Measure)
在scenario
页面中创建了三个tabs(Package, Source and Measure)
。
I need to render
the three tabs
to call each one of the above controller
and views
like Package
should do the action of create, edit, update and destroy of Packages controller
and vice-verse. 我需要
render
three tabs
来调用上述controller
每个controller
并且像Package
views
应执行create, edit, update and destroy of Packages controller
,反之亦然。
How should i call those three different controller
actions in the Scenario
page? 如何在“
Scenario
页面中调用这三种不同的controller
动作? I want all the three into the single page and work within their tabs
. 我希望所有这三个都进入单个页面并在它们的
tabs
工作。
What shall i include in the index, new, create, edit and update methods in Scenario controller? 我应该在Scenario Controller中的索引,新建,创建,编辑和更新方法中包括哪些内容? Do i need to create all the view files for scenario too?
我是否还需要为场景创建所有视图文件?
Any help would be more appreciated. 任何帮助将不胜感激。
PS I tested all the three are working fine with their separate pages. PS我测试了所有这三个在各自的页面上都可以正常工作。
best to use ajax calls and render the view templates within the respective tab with js/erb template. 最好使用ajax调用,并使用js / erb模板在相应选项卡中呈现视图模板。 eg,
例如,
show.js.erb show.js.erb
$('<%= @selector %>').html("<%= escape_javascript(render(:action => :show)) %>");
if you wanna use this same ajax call to render show action elsewhere, then send a selector as a request param depending on which page you are on: eg, when you are on the scenario page and the div id for package tab is say 'package-tab', then send selector '#package-tab'
as param and set @selector to this in your controller. 如果您想使用同一ajax调用在其他位置渲染show动作,则根据您所在的页面将选择器作为请求参数发送给您:例如,当您在场景页面上并且package选项卡的div id为'package -tab”,然后将选择器
'#package-tab'
作为参数发送,并在控制器中为此设置@selector。 with this you can control from the request which dom-element is refreshed by the ajax call. 这样,您可以从请求中控制通过ajax调用刷新哪个dom-element。
does this answer the question? 这会回答问题吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.