本文介绍了在 rails 中创建一个包含许多链接的下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有很多链接,例如link1、link2、link3、link4 ...link9.我必须在下拉菜单中添加这些链接.我尝试使用 rails select_tag 和 html 标签
使用 html 选择标签
<option value="link1"><%= link_to "link1", "#",{:remote =>真,'数据切换' =>模态",数据目标"=>'#modal-window'} %></option><option value="link2"><%= link_to "link2", "#",{:remote =>真,'数据切换' =>模态",数据目标"=>'#modal-window'} %></option><option value="link3"><%= link_to "link3", "#",{:remote =>真,'数据切换' =>模态",数据目标"=>'#modal-window'} %></option>......<option value="link9"><%= link_to "link9", "#",{:remote =>真,'数据切换' =>模态",数据目标"=>'#modal-window'} %></option></选择></span>
如何制作多个链接的下拉列表
解决方案
我是通过以下方式做到的.为此,我参考 bootstrap button dropdowns
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">操作 </span>按钮><ul class="dropdown-menu" role="menu"><li><%= link_to "link1", "#",{:remote =>真,'数据切换' =>模态",数据目标"=>'#modal-window'} %></li><li><%= link_to "link1", "#",{:remote =>真,'数据切换' =>模态",数据目标"=>'#modal-window'} %></li><li><%= link_to "link3", "#",{:remote =>真,'数据切换' =>模态",数据目标"=>'#modal-window'} %></li><li class="divider"></li><li><%= link_to "link4", "#",{:remote =>真,'数据切换' =>模态",数据目标"=>'#modal-window'} %></li>
I have many links about for example link1, link2, link3, link4 ...link9.I have to add those links in the drop down. I tried with rails select_tag and also with html tag
Using html select tag
<span class="device_update">
<select>
<option value="link1"><%= link_to "link1", "#",{:remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window'} %></option>
<option value="link2"><%= link_to "link2", "#",{:remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window'} %></option>
<option value="link3"><%= link_to "link3", "#",{:remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window'} %></option>
......
<option value="link9"><%= link_to "link9", "#",{:remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window'} %></option>
</select>
</span>
How can I make drop down lists of many links
解决方案
I did this by following way. For this I refer bootstrap button dropdowns
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
Action <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><%= link_to "link1", "#",{:remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window'} %></li>
<li><%= link_to "link1", "#",{:remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window'} %></li>
<li><%= link_to "link3", "#",{:remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window'} %></li>
<li class="divider"></li>
<li><%= link_to "link4", "#",{:remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window'} %></li>
</ul>
</div>
这篇关于在 rails 中创建一个包含许多链接的下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!