1
我是Backbone和REST API的新手。這裏是我的保存功能代碼:Backbone.js model.save()函數不成功
this.model.save(this.model.attributes,
{
success: function (model) {
app.menuItems.add(model);
app.navigate('/w/backbone/', {trigger: true});
}
}
);
,這裏是我的模型:
var MenuItem = Backbone.Model.extend({
urlRoot: '/w/backbone/rest/items',
idAttribute: 'taskId',
defaults: {
category: 'Entreés',
imagepath: 'no-image.jpg',
name: ''
}
});
,這裏是我的RESTful的API POST功能:
function items_post()
{
// add an existing user and respond with a status/errors
$array=array(
'item_id'=>$this->post('id'),
'item_url'=>$this->post('url'),
'item_name'=>$this->post('name'),
'item_category'=>$this->post('category'),
'imagepath'=>$this->post('imagepath')
);
$this->main_model->add_item($array);
}
而你的問題是? – tlenss