jquery - Twitter typeahead no result when using “prefetch”, but working with “remote” JSON -
jquery - Twitter typeahead no result when using “prefetch”, but working with “remote” JSON -
i´m struggling whole day. typeahead search look works perfect remote json data. when seek utilize same json info prefetched data, suggestion empty. after hitting first sign predefined message "unable find t..." empty result.
here script:
function initialtypeaheadtest(){ var mo_selector = $('*[data-mot="mysearch"]'); var engine = new bloodhound({ limit: 10 ,prefetch: {url:'/api/action/getjsontest'} //,remote: {url:'/api/action/getjsontest'} ,datumtokenizer: bloodhound.tokenizers.obj.whitespace('name') ,querytokenizer: bloodhound.tokenizers.whitespace }); engine.clearprefetchcache(); // test purposes engine.initialize(); mo_selector.typeahead( { hint: true, highlight: true, minlength: 1 }, { name: 'engine', displaykey: 'name', source: engine.ttadapter(), templates: { empty: [ '<div class="empty-message">', 'unable find match current query', '</div>' ].join('\n'), suggestion: handlebars.compile([ '<div id="{{value}}"><p style="max-height:100%;"><strong>{{title}}</strong></p>', '<span style="font-size:12px;">{{year}}</span></div>' ].join('')) } }); } and thats json:
[{ "year":"02 feb 2013 @ 00:40 anonymous", "title":"javascript html dom changing html content", "value":"1", "tokens":["javascript", "html", "dom", "changing", "html", "content"] },{ "year":"02 feb 2013 @ 00:42 anonymous", "title":"wdr.de", "value":"2", "tokens":["wdr.de"] },{ "year":"02 feb 2013 @ 00:46 anonymous", "title":"nachrichten, aktuelle schlagzeilen und videos - n-tv.de", "value":"3", "tokens":["nachrichten", "aktuelle", "schlagzeilen", "und", "videos", "n", "tv.de"] },{ "year":"02 feb 2013 @ 00:55 anonymous", "title":"javascript regexp object", "value":"5", "tokens":["javascript", "regexp", "object"] },{ "year":"15 feb 2013 @ 23:24 anonymous", "title":"dotnetnuke module auto listing module", "value":"8", "tokens":["dotnetnuke", "module", "car", "listing", "module"] },{ "year":"08 feb 2014 @ 01:08 advertiser", "title":"empfehlung", "value":"1000", "tokens":["empfehlung"] }] original path: mattopen.com/api/action/getjsontest
for me, looks good. json info formed. strings (e.g. in tokens) quoted in double quotes well. why remote info working prefetch not?
can point me in right direction? thanks
jquery json bootstrap-typeahead twitter-typeahead
Comments
Post a Comment