Jquery令牌输入自动完成功能无法在带有rails 3的facebook friends数组上运行

时间:2011-10-17 10:08:43

标签: jquery ruby-on-rails ruby ruby-on-rails-3

我正在使用本教程从您的Facebook好友处理自动填充的文本字段:http://railscasts.com/episodes/258-token-fields?autoplay=true

我在js控制台中遇到了这个错误:

Uncaught TypeError: Cannot call method 'replace' of undefined highlight_termjquery.tokeninput.js:609 $.TokenList.selected_dropdown_itemjquery.tokeninput.js:628 jQuery.extend.eachjquery.js:641 populate_dropdownjquery.tokeninput.js:627 run_searchjquery.tokeninput.js:704 $.TokenList.ajax_params

我的代码是:

JS:

$(function() {
  $("#when").datetimepicker();
  $("#who").tokenInput("/memberships.json", {
    crossDomain: false,
    theme: "facebook"
  });
});

HTML:

<% form_for @doweet, :html => { :id => "post" } do |f| %>

<%= error_messages_for @doweet %>

<%= f.text_field :doweet_member_tokens,  :id => "who", :placeholder => "Who?" %>  

<%= f.submit "Doweet" %>

轨:

memberships.json:

q = params[:q]
@friend_members = FbGraph::Query.new("SELECT name,uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY name asc").fetch(current_user.token).collect { |f| f["name"] }.select { |v| v =~ /#{Regexp.escape(q)}/i  } 
respond_to do |format|
  format.html
  format.json { render :json => @friend_members }
end

我从这个阵列中回来了:[“Shlomi Caduri”,“Shlomit Harth”]

doweet.rb:

  attr_reader :doweet_member_tokens

  def doweet_member_tokens=(ids)
    self.doweet_member_ids = ids.split(",")
  end

正确附加了js和css文件。

我做错了什么?

非常感谢,

加仑

0 个答案:

没有答案