Model save backbone

2019-02-26 05:21发布

I'm saving a model on a online db Parse.com. The save function works perfectly but the callback function inside save are not called.

this.utente.save( {
                  success: function (persona) {//never called
                      console.log("modello salvato nel db");
                    console.log(persona);

                  },

                  error: function (data){//never called

                      console.log(data)
                  }


                });

1条回答
太酷不给撩
2楼-- · 2019-02-26 06:08

Backbone.Model#save takes options in the second argument:

save model.save([attributes], [options])

Save a model to your database (or alternative persistence layer), by delegating to Backbone.sync.

If you want to call save without any particular attributes and you want to supply options, say:

model.save(null, { ... })

You probably want to say:

this.utente.save(null, {
    success: function (persona) { ... },
    error: function (data) { ... }
});
查看更多
登录 后发表回答