mercredi 15 février 2017

How to use Bootstrap-3-Typeahead work with embe-data?

My ember version:

DEBUG: -------------------------------
Ember             : 2.11.0
Ember Data        : 2.11.1
jQuery            : 3.1.1
Ember Simple Auth : 1.2.0
DEBUG: -------------------------------

Before I use ember data, I have a component like this:

import Ember from 'ember';

export default Ember.TextField.extend({
  didInsertElement: function() {
    var _this = this;
    this.$().typeahead({
      source: function(query, process) {
        $.getJSON("/api/" + _this.get('modelName'), {query: query, access_type: 'typeahead'}, function(data) {
          process(data);
        });
      }
    })
  },

  willDestroyElement: function() {
    this.$().typeahead('destroy');
  }
})

Use this component:



And this component work with Bootstrap-3-Typeahead(http://ift.tt/Ppw3YT).

But when I use ember-data to my project, I did not know how to use Bootstrap-3-Typeahead work with ember-data. Because all data came from this.store.query('order'), not use ajax any more.

So if I must use typeahead, I must design a addo? Thanks.

Aucun commentaire:

Enregistrer un commentaire