@niconel wrote:
My api is Asp.net web api, so I'm using the web-api adapter and serializer (both empty, other than the api url in the adapter)
I can get data from my api just fine, and after a bit of struggle, manage to hit the put and post methods as well (all running locally, so I can debug)
I'm going back to the books on this, but while doing so figured I'd ask: Like I said I can do a GET fine and get the data back (api model and ember model exactly the same, and I use the same model for the PUT and POST's)
When I do an update or create (thus ember do a PUT or POST) it does call the correct api method, but the object received have all it's properties empty, so not sure what I'm doing wrong here?
export default Ember.Route.extend({
model() { return this.store.createRecord('deal'); }, actions : { saveDeal(newDeal) { newDeal.save().then(() => this.transitionTo('deals')); } .....
Just occured to me to create a test model (both in api and in ember) with straight text fields, since this "deal" form have several instances of a custom component I created. It just render a dropdown with options, so not sure why that would be a problem (some code below for in case....?)
{{select-component datatype='dealtype' selectedId=model.dealType.id}}
....
export default Ember.Component.extend({
tagName: 'select', classNames: ['form-control'], datatype: '', items: [], selectedId: 0, store: Ember.inject.service(), didReceiveAttrs : function(){ this._super(...arguments); Ember.run.scheduleOnce('afterRender', this, this.afterRenderEvent); }, afterRenderEvent : function(){ var store = this.get('store'); let items = store.findAll(this.get('datatype')); this.set('items', items); Ember.run.later(function() { Ember.$('select').select2(); }); }
});
.....
{{#each items as |item|}} {{#if (eq selectedId item.id)}} <option selected="selected" value="{{item.id}}">{{item.name}}</option> {{else}} <option value="{{item.id}}"> {{item.name}} </option> {{/if}} {{/each}}
Posts: 1
Participants: 1