如何在Rhomobile中将变量传递给Partial

如何在Rhomobile中将变量传递给Partial

本文介绍了如何在Rhomobile中将变量传递给Partial的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个局部需要显示变量catchedEvent的值,

I have a partial where i need show the value of variable catchedEvent,

部分

<div class="eventList">Here to show the value of the variable</div>

在我的erb页面上,我使用

On my erb page i'm calling this using

<%= render :partial =>"mypartial" %>

我无法将变量传递给它.请帮忙.

I can't get the way to pass the variable to it. Please help.

推荐答案

您可以使用此处指定的本地或集合 http://docs.rhomobile.com/rhodes/ui#advanced-usage-of-render

You can use the locals or collections as specified over here http://docs.rhomobile.com/rhodes/ui#advanced-usage-of-render

<%= render :partial =>"mypartial", :locals => { :event => "myevent" } %>

然后局部使用,像

<div class="eventList"><%= event %></div>

第二,如果您为控制器中的实例变量分配了一些值,

Second, if you assign some value to the instance variable in the controller,

@event = "myevent"

然后您可以在部分内部直接访问它,

then you can directly access it inside the partial as below,

<div class="eventList"><%= @event %></div>

这些是您可以用来传递变量的一些方法.

These are some of the ways you can use to pass the variables.

这篇关于如何在Rhomobile中将变量传递给Partial的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 22:25