Giter Club home page Giter Club logo

Comments (9)

sergeyt avatar sergeyt commented on June 29, 2024

@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.

francisbyrne avatar francisbyrne commented on June 29, 2024

@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.

sergeyt avatar sergeyt commented on June 29, 2024

@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.

francisbyrne avatar francisbyrne commented on June 29, 2024

@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.

sergeyt avatar sergeyt commented on June 29, 2024

@isocra please update/close the issue to reflect it's status

from meteor-typeahead.

isocra avatar isocra commented on June 29, 2024

Yup, adding Meteor.typeahead.inject(); did the trick.

Thanks for your help :-)

from meteor-typeahead.

titocosta avatar titocosta commented on June 29, 2024

Adding Meteor.typeahead.inject() to Template.myTemplate.rendered callback fixed it for me. Leaving it in Meteor.startup() didn't work.

from meteor-typeahead.

nickeleres avatar nickeleres commented on June 29, 2024

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.

Jayuda avatar Jayuda commented on June 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.