When I did not use Ember-data, my select2
component like:
import Ember from 'ember';
export default Ember.TextField.extend({
didInsertElement() {
var _this = this;
this.$().select2({
placeholder: "waiting...",
minimumInputLength: 1,
ajax: {
url: "/api/fitting_items/select_search",
dataType: 'json',
quietMillis: 250,
data(term, page) {
return {
q: term,
stock_type: _this.get('stockType'),
stock_id: _this.get('stockId')
}
},
results(data, page) {
return {
results: data.fitting_items
}
},
cache: true,
}
});
},
willDestroyElement() {
this.$().select2('destroy');
}
})
ember-simple-auth 0.7.3
But I update my project now, I use
DEBUG: -------------------------------
DEBUG: Ember : 2.4.3
DEBUG: Ember Data : 2.4.3+a3e2521f85
DEBUG: jQuery : 2.2.2
DEBUG: Ember Simple Auth : 1.0.0
DEBUG: -------------------------------
And the ember-data
use json-api
, so my select2
component has some problem.
-
If I use
select2
ajax, I must settoken
in the header. BecauseEmber Simple Auth : 1.0.0
must settoken
by myself if I set custom ajax requet. -
I think if I use
select2
ajax
is not ember data way. It maybe usethis.store.query('fittingItem', params)
will better. -
If I do not use
select2
, I write a component likeselect2
is too difficult for me.
So to sum up, I should use what kind of method to solve this problem is better? Thanks.
Aucun commentaire:
Enregistrer un commentaire