jQuery自动完成:TypeError:this.source不是函数

时间:2017-03-14 11:41:36

标签: javascript jquery ruby-on-rails ruby haml

我在两个输入字段(名称和活动)上实现了自动填充功能。使用Safari或FireFox时,该框不会显示在名称输入字段中。在控制台中显示以下错误消息:

  

TypeError:this.source不是函数。 (在'this.source({term:value},this._response())','this.source'为null)

= simple_form_for @transaction do |f|
      .span
        = f.input_field :receiver,  as: :autocomplete, source_query: autocomplete_user_name_users_url, field_id: false,  placeholder: 'To', required: true , :autofocus => true
      .span
        = f.input_field :amount, input_html:{ min: '0', max: '999', step: 'any'} , placeholder: 'Amount', required: true
      .span
        = f.input_field :activity, as: :autocomplete, source_query: autocomplete_activity_name_activities_url, field_id: false, placeholder: 'For',required: true
      = f.submit

这些是控制器

class ActivitiesController < ApplicationController
  autocomplete :activity, :name
end

class UsersController < ApplicationController
  autocomplete :user, :name
end

我的application.js

//= require jquery
//= require bootstrap-sprockets
//= require bootstrap3-typeahead
//= require bootstrap3-autocomplete-input
//= require jquery_ujs
//= require later
//= require kudosclicker
//= require simple_form_autocomplete
//= require_tree .

知道我做错了吗?

0 个答案:

没有答案