【问题标题】:Rails 4 - Uikit Single Quotes - Autocomplete syntaxRails 4 - Uikit 单引号 - 自动完成语法
【发布时间】:2016-02-29 23:18:00
【问题描述】:

我正在使用 Rails 4.2.4 和 UiKit 2.25.0。我正在尝试使用自动完成组件将我的用户加载到表单中。实现非常简单(我认为)。

我的主要问题是关于语法。

我正在尝试在我的节目中复制这种语法

<div class="uk-autocomplete uk-form" data-uk-autocomplete="{source:'my-autocomplete.json'}">
    <input type="text">
</div>

但我不断收到此信息(您可能需要水平滚动才能看到):

<form class="uk-autocomplete uk-form" id="new_collaboration" data-uk-autocomplete="{source: &#39;users_path&#39;}" action="/lists/3/collaborations" 
  <label for="Enter_collaborator_username">Enter collaborator username</label>
  <input type="text" name="username" id="username" />
  <input type="submit" name="commit" value="Add collaborator" />
 </form>

我想在我的 json 文件的源周围加上单引号,但我得到了

&#39; --> data-uk-autocomplete="{source: &#39;users_path&#39;}

我在源代码中没有看到单引号这一事实是否是它不起作用的原因?

我已尝试转义它们 (\'),但它们仍显示为 '。

这里是 Uikit 自动完成的链接http://getuikit.com/docs/autocomplete.html

感谢任何人提供的任何帮助,如果有人需要我提供更多信息,请告诉我。

谢谢!

【问题讨论】:

    标签: jquery ruby-on-rails autocomplete


    【解决方案1】:

    你可以试试这样的:

    <%= content_tag(:div, data: { 'uk-autocomplete': "{source:'# {users_path}', method: 'get'}" }) do %>
      <input type="text">
    <% end %>
    

    【讨论】:

      猜你喜欢
      • 2017-02-07
      • 2015-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-23
      • 2014-02-23
      相关资源
      最近更新 更多