简体   繁体   中英

Ember Put and Post Request without Ember-Data

I have built a model from GET request and display the content that I need into a form, mainly dropdown options. User then completes the form and 'POST' back to the api. The API that I am using isn't formatted in a way that I can use for ember-data so I have opted to render my model with Ember.Object

var Prequalification = Ember.Object.extend();

Prequalification.reopenClass({
    template: function(){
        return Ember.$.ajax({
            url: "/prequalification",
            dataType: 'json'
        }).then(function(response){
            var template = response.collection.template.data;

            return template;
        });
    }
});

export default Prequalification;

My controller decorates the view:

var IndexController = Ember.ArrayController.extend({
    businessType: function(){
        var content = this.get('content');
        console.log(this);
        return content.get(10);
    }.property('content'),
    loanType: function(){
        var content = this.get('content');
        return content.get(5);
    }.property('content')
});

export default IndexController;

So on form submit, what are my options for Posting back to the API?

Thanks!

Use an action and associate it with a button.

actions: {
    save: function(){
      alert('ajax save here');
    }
  }

http://emberjs.jsbin.com/jositowa/1/edit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM