开发者

jquery ui autocomplete results not rendering even though response received

I'm using the jquery ui autocomplete in a Rails application, and my results aren't rendering. In firebug, I'm getting a 304 not modified error, even though under the response I see the correct string responses as an array.

Here's my code:

the autocomplete controller:

class AutocompleteController < ApplicationController
  respond_to :json

  # result is array of strings eg: ["foo", "foobar", "foobarbat"]
  def work_fandom
    @results = redis_tag_lookup(params[:term])
    respond_with(@results)
  end
end

In application.js:

// Autocomplete
jQuery(function($){
  $('.autocomplete').each(function(){
    var self = $(this);
    self.autocomplete({
        source: self.attr('autocomplete_method'),
        minLength: 3
    });
  });
});

In the view after loading:

<开发者_Python百科input aria-haspopup="true" aria-autocomplete="list" role="textbox" autocomplete="off" 
autocomplete_method="/autocomplete/work_fandom" class="autocomplete ui-autocomplete-input ui-autocomplete-loading" 
id="work_fandom" name="work[fandom_string]" value="" type="text">

Any suggestions welcome!


Try respond_with(@results.to_json)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜