【发布时间】:2013-01-25 15:02:04
【问题描述】:
我还没有看到这方面的任何文档..
如果我有
<%= best_in_place @user, :city, type=> :input, %>
我需要包含 data-provide="typeahead"
<%= best_in_place @user, :city, type=> :input,:data => {:provide => "typeahead"} %>
并包含来源
<%= best_in_place @user, :city, :type=> :input, :data => {:provide => "typeahead", :source => City.getcities.to_json} %>
假设 City.getcities.to_json 返回带有城市名称的正确 json 列表
这行不通……
【问题讨论】:
-
你可以试试
<%= best_in_place @user, :city, :type=> :input, :html_attrs => {:'data-provide' => "typeahead", :'data-source' => City.getcities.to_json} %> -
这是一个改进。似乎有效,但只有当我用键盘而不是鼠标从列表中选择时..这是一个提前输入的问题吗?
-
我无法尝试,所以这可能是 bootsrap 中的问题,也可能与 best_in_place 发生冲突,因为 best_in_place 还订阅了输入模糊和 keyup 事件...
-
$('ul.typeahead').live('mousedown', function(e) { e.preventDefault(); });似乎可以处理它
标签: ruby-on-rails-3 twitter-bootstrap best-in-place bootstrap-typeahead