我试图将data-trigger属性添加到表单中,但是每次添加data-trigger时,都会出现语法错误。我已经尝试使用带有括号和方括号以及等号的不同语法,但是似乎没有任何作用。
这是我的观点:
<div class="container">
<div class="s003">
<%= search_form_for @search, url: search_path, remote: true do |f| %>
<div class="inner-form">
<div class="input-field first-wrap">
<div class="input-select">
<%= f.select :wine_type_gteq, [["Riesling", "Riesling"], ["Gewürztraminer", "Gewürztraminer"], ["Chardonnay", "Chardonnay"], ["Sauvignon Blanc", "Sauvignon Blanc"],
["Weißburgunder", "Weißburgunder"], ["Grauburgunder", "Grauburgunder"], ["Spätburgunder", "Spätburgunder"], ["Tempranillo", "Tempranillo"], ["Pinotage", "Pinotage"], ["Shiraz", "Shiraz"], ["Cabernet Sauvignon", "Cabernet Sauvignon"],
["Merlot", "Merlot"], ["Syrah", "Syrah"], ["Pinot Noir", "Pinot Noir"], ["Cabernet Franc", "Cabernet Franc"], ["Malbec", "Malbec"], ["Garnacha", "Garnacha"], ["Sangiovese", "Sangiovese"]], id: "wine_type", prompt: "Select..." %>
</div>
</div>
<div class="input-field second-wrap">
<%= text_field_tag :search, params[:search], placeholder: "Wein...", class: "form-control", id: "autolocation" %>
</div>
<div class="input-field third-wrap">
<button class="btn-search">
<%= submit_tag "Suchen", style: "color:white" %>
</button>
</div>
</div>
<% end %>
</div>
</div>
<script>
const choices = new Choices('[data-trigger]',
{
searchEnabled: false,
itemSelectText: '',
});
我想实现:
<div class="input-select">
<select data-trigger="" name="choices-single-defaul">
<option>Category</option>
<option>Category</option>
<option>Category</option>
<option>Category</option>
<option>Category</option>
<option>Category</option>
<option>Category</option>
<option>Category</option>
</select>
</div>
答案 0 :(得分:0)
<%= f.select :wine_type_gteq, [["Riesling", "Riesling"],...], { prompt: "Select..." }, id: "wine_type", data: { trigger: 'something' } %>