sergeyt / meteor-typeahead

Autocomplete package for meteor powered by twitter typeahead.js
https://atmospherejs.com/sergeyt/typeahead
MIT License
146 stars 82 forks source link

All serach parameters are undefined #86

Closed DavidSichau closed 9 years ago

DavidSichau commented 9 years ago

I want to use a server side autocomplete search. However the parameters to the search options are all undefined.

Here is my Template:

Template.usersTypeahead.onRendered(function () {
    console.log('rendered');
    Meteor.typeahead.inject();
});

Template.usersTypeahead.helpers({
    search: function(query, sync, callback) {
        console.log(query); //is undefined
        console.log(sync); //is undefined
        console.log(callback); //is undefined
        if(_.isString(query)) {
            Meteor.call('getUsers', query, function (err, res) {
                if (err) {
                    console.log(err);
                    return;
                }
                console.log(res);
                callback(res);
            });
        }
    },
    selected: function(event, suggestion) {
        Template.instance().userId.set(suggestion.id);
    }
})

And here the HTML

<template name="usersTypeahead">
    <div class="form-group">
    <input class="form-control typeahead" name="users" type="text"
           placeholder="Mitstudenten"
           autocomplete="off" spellcheck="off"
           data-hint="false"
           data-min-length="1"
           data-source="search" data-selected="selected"
           />
    </div>

</template>

The console looks like:

rendered
undefined
undefined
undefined
undefined
undefined
undefined

Why does the paramters are all undefined? I tried it with Version 0.10.14_14 and 0.11.1_1.

Manto commented 9 years ago

seeing the same thing here since updating. 0.10.5_14 is the latest known working version for me.

sergeyt commented 9 years ago

@DavidSichau, @Manto AFAIR last time server-side search was working in demo app in my meteor environment. I guess this could be caused with changes in internal meteor API that this package uses (e.g. Template._withTemplateInstanceFunc). I'll try to debug and fix the issue this week.

sergeyt commented 9 years ago

BTW I've checked in demo app server-side search is working without observation of this issue.

Manto commented 9 years ago

you were right @sergeyt. my issue was with kadira-debug; not this package. my bad :)