typeahead.js - Cannot read property 'tokenizers' of undefined using Typeahead -
i using twitter's "typeahead.js 0.11.1", got error "cannot read property 'tokenizers' of undefined". put code below, please me check did wrong.
paths: { 'jquery' : 'assets/lib/jquery.min', 'underscore' : 'assets/lib/underscore-min', 'backbone' : 'assets/lib/backbone.min', 'marionette' : 'assets/lib/backbone.marionette.min', 'bootstrap' : 'assets/lib/bootstrap.min', 'typeahead' : 'assets/lib/typeahead.bundle.min', }, shim: { typeahead:{ deps: ['jquery'], exports:'bloodhound', init: function ($) { return require.s.contexts._.registry['typeahead.js'].factory( $ ); } } }
marionette's view code below:
define(['jquery', 'marionette','templates', 'underscore','typeahead'], function $,marionette, templates, _,bloodhound) { 'use strict'; .................. onshow:function(){ var tours = new bloodhound({ datumtokenizer: function (datum) { return bloodhound.tokenizers.whitespace(datum.value); }, querytokenizer: bloodhound.tokenizers.whitespace, remote: { url: '/api/infos?t=all', } }); // initialize bloodhound suggestion engine tours.initialize(); // instantiate typeahead ui $('.typeahead').typeahead(null, { displaykey: 'value', source: tours.ttadapter() }); },
i had similar issue backbone/marionette , requirejs configuration. important point right, require typeahead.jquery.js , bloodhound.js using separate files. using typeahead.bundle.js , not work. posting after not few hours of frustration.
Comments
Post a Comment