[英]Tooltip for options_from_collection_for_select on Rails
[英]ActionView: options_from_collection_for_select in rails view
我在Rails項目中有選擇視圖,它可以正常工作。 我想添加一個未來,但我做不到。
這是我的控制器代碼:
def new_feedback
@campaigns = Campaign.all
render "new_feedback", layout: false if request.xhr?
結束
這是我的視圖代碼的一部分:
<label>Campaign: (<span class="required-star">*</span>)</label><br>
<%= f.select "campaign_id", options_from_collection_for_select(@campaigns, :id, :name), {prompt: ''}, class: 'campaign-select feedback-campaign', required: true %><br>
上面的代碼可以正常工作。 我想添加一些內容作為我選擇的廣告系列。 它下面的代碼應為:
<% if (I selected campaign) id==265) %>
...something here...
<%end%>
我應該寫些什么而不是“(我選擇的廣告系列)”呢? 誰能幫我。
如果您位於表單塊中:
f.object.campaign_id == 265
您必須認為這將在呈現頁面時運行一次。 如果要基於用戶交互動態地執行某些操作,則必須使用javascript。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.