你好我要疯了! 我用所有可能的方式设置了 jquery.tokeninput 并且仍然显示带有预数据的空值!请有人能告诉为什么会这样?
我尝试了所有但仍然不知道为什么这个空
这是代码
$(document).ready(function () {
$("#item_tags").tokenInput("/tags.json", {
crossDomain: false,
prePopulate: $("#item_tags").data("pre"),
animateDropdown: false,
theme: "facebook",
allowFreeTagging: true,
preventDuplicates: true,
hintText: "Adicionar categorias",
searchingText: "buscando...",
allowCreation: true,
creationText: "Adicionar",
tokenValue: "name",
});
});
def index
#@tags = Tag.order(:name)
@tags = Tag.where("name like ?", "%#{params[:q]}%")
respond_to do |format|
format.html
#format.json { render json: @tags.tokens(params[:q]) }
format.json {render :json => @tags.collect{|t| {:id => t.name, :name => t.name }}}
end
end
resources :tags
听起来你在使用 jquery.tokeninput 插件时遇到了问题。