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

Multiple datasets - view #91

Closed samurai-jack closed 9 years ago

samurai-jack commented 9 years ago

Where is my mistake? Instead Boston Celtics I get "_query":"b","undefined":"Boston Celtics" I get code from http://typeahead.meteor.com

I also installed a demo application from the website https://github.com/sergeyt/meteor-typeahead/tree/master/demo and the results in the "multiple datasets" is as follows.: {"_id":"oMSzRTiL3rLEwJ5sZ","name":"Boston Celtics"}

Please help

demo.html

<head>
  <title>hello</title>
</head>

<body>
  {{> hello}}
</body>

<template name="hello">
            <input class="form-control typeahead" name="team" type="text"
       placeholder="NBA and NHL teams"
       autocomplete="off" spellcheck="off"
       data-sets="teams"/>
</template>

demo.js

Nba = new Meteor.Collection("nba"); 
Nhl = new Meteor.Collection("nhl");

if (Meteor.isServer){
    Nba.insert({name:'Boston Celtics'});
        Nhl.insert({name:'New York Islanders'});
}

if (Meteor.isClient) {
    Template.hello.teams = function(){
    return [
        {
            name: 'nba-teams',
            local: function() { return Nba.find().fetch().map(function(it){ return it.name; }); },
            # header: '<h3 class="league-name">NBA Teams</h3>'
        },
        {
            name: 'nhl-teams',
            local: function() { return Nhl.find().fetch().map(function(it){ return it.name; }); },
            header: '<h3 class="league-name">NHL Teams</h3>'
        }
    ];
};

  Template.hello.rendered = function() {
    Meteor.typeahead.inject();
  }
}
sergeyt commented 9 years ago

@samurai-jack http://typeahead.meteor.com is out-dated, see demo app in this repo

sergeyt commented 9 years ago

closing since demo app has working example