How to pass variables to partial in Rhomobile

≡放荡痞女 提交于 2019-12-24 16:33:09

问题


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

Partial

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

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.


回答1:


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" } %>

Then on partial, use it like

<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.



来源:https://stackoverflow.com/questions/18798878/how-to-pass-variables-to-partial-in-rhomobile

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!