TypeError:$(...)。typeahead不是函数

时间:2018-03-12 15:12:34

标签: jquery ruby-on-rails ruby-on-rails-5 typeahead.js searchkick

关于如何解决这个问题,我已经2天了。我在我的rails 5.1.2 app中使用了searchkick + typeahead。尝试了放置// = require typeahead.bundle.js(在jquery上方/下方)的所有组合,但错误永远不会消失。下面是我的application.js文件

//= require wNumb.js
//= require twitter/typeahead
//= require typeahead.bundle.min
//= require typeahead.bundle
//= require typeahead
//= require nouislider
//= require jquery
//= require jquery-ui
//= require jquery.particleground.min
//= require jquery_ujs
//= require popper
//= require thesaas.min.js
//= require core.min.js
//= require noty.js
//= require bootstrap
//= require layout.js
//= require bootstrap-checkbox.min.js
//= require switch.min.js
//= require switchery.min.js
//= require jquery.sparkline.min.js
//= require tether.min.js
//= require moment-with-locales.min.js
//= require bootstrap-datetimepicker.min.js
//= require legacy.js
//= require daterangepicker.js
//= require app-menu.min
//= require vendors.min
//= require app.min
//= require morris.min.js
//= require echarts.js
//= require unslider-min.js
//= require raphael.min.js
//= require icheck.min
//= require utils.min.js
//= require checkbox-radio.min.js
//= require jquery.steps.min.js
//= require jquery.bootstrap-touchspin.js
//= require turbolinks
//= require cocoon
//= require dropzone
//= require underscore
//= require gmaps/google
//= require jquery.validate.min.js
//= require gauge.min.js
//= require odometer.js
//= require chat-application.js
//= require wow.js
//= require social-share-button
//= require_self

现在正在从application.js调用脚本(也是从articles.js尝试过,但是没有用),

$(document).ready(function (){
    var articles = new Bloodhound({
        datumTokenizer: Bloodhound.tokenizers.whitespace,
        queryTokenizer: Bloodhound.tokenizers.whitespace,
        remote: {
            url: '/articles/autocomplete?query=%QUERY',
            wildcard: '%QUERY'
        }
    });
    $('#articles_search').typeahead(null, {
        source: articles
    });
});

但我仍然得到' TypeError:$(...)。typeahead不是函数'。这是一个jquery问题吗?

0 个答案:

没有答案