How to pass variables to partial in Rhomobile

2019-08-09 03: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条回答
小情绪 Triste *
2楼-- · 2019-08-09 03:35

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.

查看更多
登录 后发表回答