handlebars.js - Customizing PUT route on save method in ember.js -
i manually specify put route saving model. possible ember?
for example, have conversation model , when call conversation.save(), don't want search put conversations/somemail/conversations/:id manually tell ember use put /conversations/:id instead.
here namespace :
app.applicationadapter.reopen({ namespace: 'conversations/someemail' });
router :
app.router.map(function(){ //routing list raw namespace path this.resource('conversations', { path : '/' }, function() { this.resource('conversation', { path : '/:conversation_id'}); }); });
model :
app.conversation = ds.model.extend({ readstatus: ds.attr('string'), url: ds.attr('string'), status: ds.attr('string'), lastmessage: ds.attr('string'), createdat: ds.attr('string'), timeagoelement: ds.attr('string'), customer: ds.belongsto('customer'), content: ds.attr('array'), });
you can customize url in adapter overriding buildurl:
app.applicationadapter.reopen({ buildurl: function(type, id, record, requesttype) { if (type === 'conversation' && requesttype === 'put') { return '/conversations/' + id; } return this._super.apply(this, arguments); } });
its exact signature depends on ember version try out in app.
Comments
Post a Comment