Ruby on rails 3 如何通过twitter引导使用Best In Place
我没有看到这方面的任何文档 如果我有Ruby on rails 3 如何通过twitter引导使用Best In Place,ruby-on-rails-3,twitter-bootstrap,best-in-place,bootstrap-typeahead,Ruby On Rails 3,Twitter Bootstrap,Best In Place,Bootstrap Typeahead,我没有看到这方面的任何文档 如果我有 <%= best_in_place @user, :city, type=> :input, %> 我需要包括数据提供=提前键入 <%= best_in_place @user, :city, type=> :input,:data => {:provide => "typeahead"} %> 并包括来源 <%= best_in_place @user, :city, :type=> :in
<%= best_in_place @user, :city, type=> :input, %>
我需要包括数据提供=提前键入
<%= 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列表
这不起作用…使用:data选项,您可以在生成的跨度上而不是在输入本身上设置数据属性
如果要在生成的输入元素上添加属性,则需要使用:html\u attrs选项:
使用:data选项,您可以在生成的范围而不是输入本身上设置数据属性
如果要在生成的输入元素上添加属性,则需要使用:html\u attrs选项:
您可以尝试使用:input、:html_attrs=>{:'data-provide'=>typeahead、:'data-source'=>City.getcities.to_json}%>这是一个改进。似乎有效,但前提是我用键盘而不是鼠标从列表中选择。。这是一个typeahead问题吗?似乎是一个引导问题,我无法尝试,所以它可能是bootsrap中的真正问题,或者它可能与best_in_place发生冲突,因为best_in_place也订阅输入模糊和键控事件…$'ul.typeahead'。live'mousedown',functione{e.preventDefault;};似乎可以处理它您可以尝试使用:input,:html_attrs=>{:'data-provide'=>typeahead,:'data-source'=>City.getcities.to_json}%>这是一个改进。似乎有效,但前提是我用键盘而不是鼠标从列表中选择。。这是一个typeahead问题吗?似乎是一个引导问题,我无法尝试,所以它可能是bootsrap中的真正问题,或者它可能与best_in_place发生冲突,因为best_in_place也订阅输入模糊和键控事件…$'ul.typeahead'。live'mousedown',functione{e.preventDefault;};似乎可以处理它根据鼠标问题,上面的解决方案对我不起作用。嗯,列表在鼠标上消失的原因在bootstrap-typeahead.js中,li上的mouseleave函数:if!this.focused&&this.show this.hide,列表被隐藏,因为最佳位置输入字段被聚焦,而不是列表。评论说行对我来说已经足够了。关于鼠标问题,上面的解决方案对我不起作用。好吧,列表在mouseover上消失的原因在bootstrap-typeahead.js中,li上的mouseleave函数:if!this.focused&&this.show this.hide,列表被隐藏,因为最佳位置输入字段被聚焦,而不是列表。评论说那句话对我来说已经足够了。
<%= best_in_place @user, :city, :type=> :input,
:html_attrs => {:'data-provide' => "typeahead",
:'data-source' => City.getcities.to_json} %>
$('ul.typeahead').live('mousedown', function(e) { e.preventDefault(); });