title: Rails: after redirect back retain input value that uses typeahead
body: <p>I have the following search form:</p>
  
  <pre><code>&lt;%= form_tag search_path, method: "get", id: "other-form"  do %&gt;
  &lt;div class="input-group"&gt;
    &lt;%= text_field_tag :address, params[:address], id:"address",
                       class: "address", placeholder: "Enter address"  %&gt;
   &lt;button class="btn btn-custom" type="submit"&gt;&lt;i class="glyphicon glyphicon-search"&gt;&lt;/i&gt;&lt;/button&gt;
  
    &lt;%= text_field_tag :search, params[:search], class: "search",
                       placeholder: "Enter keyword" %&gt;
  </code></pre>
  
  
  
  <p>this is the autocomplete - typeahead action inside the a controller:</p>
  
  <pre><code>def autocomplete
    if params[:search].present?
    render json: Item.search(params[:search], {
      fields: ["title"],
      match: :word_start,
      limit: 10,
      load: false,
      misspellings: {below: 5}
    }).map(&amp;:title).uniq
    else params[:search_other].present?
    render json: Item.search(params[:search], {
      fields: ["title"],
      match: :word_start,
      limit: 10,
      load: false,
      misspellings: {below: 5}
    }).map(&amp;:title).uniq
    end
  end
  </code></pre>
  
  <p>An this is the javascript for it:</p>
  
  <pre><code>&lt;script&gt;
  var items = new Bloodhound({
      datumTokenizer: Bloodhound.tokenizers.whitespace,
      queryTokenizer: Bloodhound.tokenizers.whitespace,
      remote: {
          url: '/items/autocomplete?search=%SEARCH',
          wildcard: '%SEARCH'
      }
  });
  
  $('#search')
      .typeahead(null, {source: items})
      .on('typeahead:selected', function(e){
      })
  &lt;/script&gt;
  </code></pre>
  
  <p>The setup I'm after is: after a search and when I hit back, to retain all the previous values in the form. Currently when I hit the back, the address value appears but not the "enter the keyword" one. Now, if I get rid of this:</p>
  
  <pre><code>$('#search')
      .typeahead(null, {source: items})
      .on('typeahead:selected', function(e){
      })
  </code></pre>
  
  <p>The "enter the keyword" value appears after I hit the back, but that is not the setup I'm, after. Any ideas on how to implement this?</p>