Comments (9)
@isocra you need to manually activate typeahead behavior calling Meteor.typeahead in your application (usually in Template.yourTemplate.rendered handler) or call Meteor.typeahead.inject to activate all typeahead instances available on the page.
from meteor-typeahead.
@sergeyt Hmmm, I'm having the same problem just trying to implement the first example in the docs. I have the following:
aab.html
<head>
<title>aab</title>
</head>
<body>
{{> hello}}
</body>
<template name="hello">
<input class="form-control typeahead" name="team" type="text"
placeholder="NBA teams"
autocomplete="off" spellcheck="off"
data-source="nba"/>
</template>
aab.js
Nba = new Meteor.Collection("nba");
if (Meteor.isServer){
Nba.insert({name:'Boston Celtics'});
// fill Nba collection
}
if (Meteor.isClient) {
Template.hello.nba = function(){
return Nba.find().fetch().map(function(it){ return it.name; });
};
Template.hello.rendered = function() {
Meteor.typeahead();
}
}
Note: I've added Meteor.typeahead() to the rendered() function. Do I need to call it with any options as per the typeahead docs e.g. {source: ???} or should it work as vanilla?
Is this perhaps related to the new Blaze templating engine?
from meteor-typeahead.
@francisbyrne Meteor.typeahead has the following parameters:
- element - (required) The DOM element to infect
- source - (optional) The custom data source, usually a function.
So try to call Meteor.typeahead(this.find('.typeahead')).
Also you could try use Meteor.typeahead.inject() as follow:
Meteor.startup(function(){
// initializes all typeahead instances
Meteor.typeahead.inject();
});
Meteor.typeahead.inject() is used in demo app.
from meteor-typeahead.
@sergeyt Thanks, inject() worked. It might be handy to include that in the docs, in your examples for future noobs like me 👍
from meteor-typeahead.
@isocra please update/close the issue to reflect it's status
from meteor-typeahead.
Yup, adding Meteor.typeahead.inject(); did the trick.
Thanks for your help :-)
from meteor-typeahead.
Adding Meteor.typeahead.inject() to Template.myTemplate.rendered callback fixed it for me. Leaving it in Meteor.startup() didn't work.
from meteor-typeahead.
I got it to work by creating a publication for the data the template helper returns in the client. You have to subscribe to the datasource if you remove autopublish package (which you should).
from meteor-typeahead.
Hello @titocosta and @isocra : I have add Meteor.typeahead.inject() on Template.myTemplate.rendered but sometimes work and others times not working.
Any sugestions ?
from meteor-typeahead.
Related Issues (20)
- notFound Template HOT 2
- Typeahead with FlowRouter HOT 7
- Could I use with "AutoForm"? HOT 2
- compatibility with twbs 4 HOT 1
- compatibility with meteorhacks:kadira-debug HOT 1
- can i search anything b/w a words HOT 1
- Not working on Meteor 1.2.1 HOT 5
- Unique assign data-source values.
- data-autoselect doesn't work HOT 3
- Searching whole words
- data-min-length setting bug HOT 1
- Server side search doesn't work in demo
- data-source parameter HOT 1
- Custom Templates not working... HOT 3
- Typeahead always shows only 5 suggestions maximum HOT 2
- How to search username with image?
- meteor 1.6.1 compatibility? HOT 5
- Updating typeahead from maintained forks HOT 5
- Can't bind and operate on typeahead element HOT 1
- Look for 2 or more fields
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-typeahead.