title: How to add a link in jquery when displaying search results
body: <p>I made an ajax search in my project, but I have a problem with adding a link into a jquery code. I can see search results, but I do not know how to get to the page of the result.</p>
  
  <p>my js code: </p>
  
  <pre><code>$(document).ready(function () {
  $('#q').bind("change input paste", function(){
      var val = $(this).val();
      $.get( "/search_suggestions?query="+val, function(data) {
        $('#results').empty();
        $('#results').show();
        $.each(data, function(index, result) {
          $('#results').append('&lt;li&gt;'+result+'&lt;/li&gt;');
          $('#results').click(function () {
              //do smth. on click
          });
        });
      });
      //do not display anything
    });
  });
  </code></pre>
  
  <p>A view:</p>
  
  <pre><code>  &lt;div&gt;
          &lt;%= form_tag('#', method: 'get', id: 'header-search', class: 'navbar-form') do %&gt;
        &lt;div class="input-group"&gt;
          &lt;%= text_field_tag(:q, (params[:q].present? ? params[:q] : nil), class: 'form-control', placeholder: 'Поиск', autocomplete: 'off') %&gt;
            &lt;i aria-hidden="true" onclick="document.getElementById('header-search').submit();"&gt;&lt;/i&gt;
            &lt;ul id="results"&gt;
              &lt;/ul&gt;
          &lt;div class="input-group-btn"&gt;
            &lt;button class="btn btn-default disabled"&gt;&lt;i class="glyphicon glyphicon-search"&gt;&lt;/i&gt;&lt;/button&gt;
          &lt;/div&gt;
        &lt;/div&gt;
     &lt;% end %&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>def search_suggestions
    query = params[:query]
    results = if params[:query].present?
              Doctor.where('name ILIKE ? OR surname ILIKE ?', "%#{query}%", "%#{query}%").select(:surname).collect(&amp;:surname)
            else
              []
            end
    render json: results
  end
  </code></pre>
  
  <p>Routes:</p>
  
  <pre><code>Rails.application.routes.draw do
  ...
   get 'search_suggestions' =&gt; 'doctors#search_suggestions', as: :search_suggestions
  end
  </code></pre>
  
  <p>Thanks.</p>