rails jquery-ui autocomplete没有返回任何内容

时间:2018-04-07 21:10:04

标签: html ruby jquery-ui autocomplete ruby-on-rails-5

我之前能够返回预定义成分列表,但现在我根本没有让它工作。想知道我是否能得到一些帮助。当我输入页面时,它根本不会建议任何自动完成。谢谢!

class Ingredient < ApplicationRecord

belongs_to :user
validates :name,  presence: true

def ingredient_name
    self.try(:name)
end

def ingredient_name=(name)
    self.ingredient = Ingredient.find_by_name(name) if name.present?
end

HTML

<div class="field">
<%= form.label :ingredient_name %>
<%= form.text_field :ingredient_name %>
</div>

application.jss

//= require jquery
//= require jquery_ujs
//= require jquery-ui/widgets/autocomplete

application.scss

/*
 *= require jquery-ui
 */

pages.coffee

jQuery ->
    $('#ingredient_name').autocomplete
        source: ['pepperoni', 'sausage', 'bacon', 'pineapple']

0 个答案:

没有答案