0

レールでオートコンプリートを試みています。レールの初心者なので、このスリムなコードをerbに変換できないので、誰か助けてください!!!

初めてのスリムファイル

# app/views/books/index.html.slim
= form_tag books_path, class: "form-inline", method: :get do
.form-group
= text_field_tag :query, params[:query], class: "form-control"
'
= submit_tag "Search", class: "btn btn-primary"
- if params[:query].present?
'
= link_to "clear", books_path

セカンドスリムファイル

 #app/views/layouts/application.html.slim
 = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.9.3/ typeahead.min.js"

3番目のスリムファイル

# app/views/books/index.html.slim
= form_tag books_path, class: "form-inline", method: :get do
.input-group.input-group-lg
- if params[:query].present?
.input-group-btn
= link_to "clear", books_path, class: "btn btn-default"
= text_field_tag :query, params[:query], class: "form-control", id: "book_search", autocomplete: "off"
.input-group-btn
 = submit_tag "Search", class: "btn btn-primary"
4

1 に答える 1

0

初め:

<%=form_tag books_path, class: "form-inline", method: :get do %>
<div class="form-group">
  <%= text_field_tag :query, params[:query], class: "form-control" %>    
  <%= submit_tag "Search", class: "btn btn-primary" %>
  <% if params[:query].present? %>    
    <%= link_to "clear", books_path %>
  <% end %>
</div>

2番:

<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.9.3/ typeahead.min.js" %>

三番:

<%= form_tag books_path, class: "form-inline", method: :get do %>
<div class="input-group input-group-lg" >
  <% if params[:query].present? %>
  <div class="input-group-btn">
    <%= link_to "clear", books_path, class: "btn btn-default" %>
 </div>
 <%= text_field_tag :query, params[:query], class: "form-control", id: "book_search", autocomplete: "off" %>
 <div class="input-group-btn">
   <%= submit_tag "Search", class: "btn btn-primary" %>
 </div>
<% end %>
</div>

ここでいつでも確認できます - http://html2slim.herokuapp.com/

楽しみ。

于 2013-10-31T07:32:48.517 に答える