gpt4 book ai didi

jquery - 在 jquery token 输入中创建 token

转载 作者:行者123 更新时间:2023-12-03 23:01:30 24 4
gpt4 key购买 nike

目前我的 jquery token 输入工作得很好。

无法创建 token ,该 token 不在列表中

我见过here ,表示此功能已实现。但没有关于我们如何使用它的文档。

任何人都可以帮助我提供文档或演示

js_js.js

    $(document).ready(function () {
$("#job_skills").tokenInput("/jobs/search_job_skills", {
theme: "facebook",
preventDuplicates: true,
hintText: 'Add skills need for job',
searchingText: 'searching skills...',
allowCreation: true,
creationText: 'Add new element'
});

});

cons_controller.rb

  def search_job_skills
search_for_json(Skill)
end

def search_for_json(model_search)
@hash = []

@search_res = model_search.where(['name LIKE ?', "#{params[:term]}%"])

@search_res.each do |tag|
@hash << { id: tag.id,
name: tag.name}
end
render json: @hash
end

最佳答案

启动时包含 allowFreeTagging: true

不幸的是,该文档已经几年没有更新了。

另请注意,如果将 allowFreeTagging 设置为 true,您将需要将 tokenValue 更改为 “name”,因为当您保存时服务器上的标签,您可能想要保存名称,而不是 ID。

这是我的代币选项

tokenOptions = {
allowFreeTagging: true,
tokenValue: 'name'
}

$('input#tag-input').tokenInput('/tags.json', tokenOptions);

这样,当用户选择标签时,名称就会发送到服务器,如果有任何新标签名称,我只需在服务器端创建它们即可。

关于jquery - 在 jquery token 输入中创建 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16091254/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com