Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After a lot of searching around the intrawebz I realized that I was making a few small critical errors. The first thing I changed was to put the javascript into <code>$j(document).ready(function(){</code> so that it now reads </p> <pre><code>$j(document).ready(function() { $j('#autocomplete').autocomplete({ source: '/contexts/1' }); }); </code></pre> <p>Not really sure why this made a difference, maybe someone can tell me.</p> <p>After I did that I saw that it was correctly sending the json request to the server and receiving something back but nothing was being put into the autocomplete menu. From this point I realized that jQuery UI autocomplete filled in the menu with the attribute of the serialized object called "value". My model didn't have this attribute. I fixed this by adding a method(virtual attribute) of "value" into my Tag.rb model file. and changed my controller so that it would return the "value" attribute along with the object. <code>format.json { render :json =&gt; @tags.to_json(:methods=&gt;:value)}</code></p> <p>Although I now had a serialized object with a 'value' attribute, it still was not working. The final step that I had to take was to have the .to_json() method not return the type of object as the root. This is found inside config/initializers/new_rails_defaults.rb</p> <p><code>ActiveRecord::Base.include_root_in_json = false</code></p> <p>After all of this I was able to get autocomplete to work in my rails project without chaining myself to a plugin that didn't have all of the features that I would have liked.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload