【问题标题】:How to add tags on selected items to jquery autocomplete?如何将所选项目上的标签添加到jquery自动完成?
【发布时间】:2016-12-09 17:37:02
【问题描述】:

我正在 Rails 中开发一个应用程序,我有这样的输入文本:

<input type="text" name="task[value]" id="task_value" class="ui-autocomplete-input" autocomplete="off">

使用 jquery 函数从下拉菜单中选择建议值,效果很好。 我的问题是:如何向所选项目添加一些 CSS?我想要像stackoverflow这样的标签(在项目附近使用“x”来删除它)。 我正在使用 gem 'bootstrap-sass', '~&gt; 3.3', '&gt;= 3.3.7' 并且我尝试了很多插件但没有结果。也许我没有以正确的方式使用它。 对不起我的英语不好。

【问题讨论】:

    标签: javascript jquery css ruby-on-rails twitter-bootstrap


    【解决方案1】:

    使用简单的表单gem,有一个input_html标签,你可以在那里传递任何html属性,例如:

    <%= simple_form_for @user do |f| %>
      <%= f.input :username, input_html: { class: 'special' } %>
      <%= f.input :password, input_html: { style: "font-size:20px;" } %>
      <%= f.input :remember_me, input_html: { value: '1' } %>
      <%= f.button :submit %>
    <% end %>
    

    来源:https://github.com/plataformatec/simple_form

    【讨论】:

      猜你喜欢
      • 2014-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-08
      • 2013-06-22
      • 1970-01-01
      相关资源
      最近更新 更多