Her*_*wan 3 html javascript php jquery backbone.js
我遇到了破坏方法的问题.我可以在我的firebug中保存并查看HTTP活动但是当我使用destroy方法时我看不到任何东西.谁能解释为什么?
Backbone.emulateHTTP = true;
Backbone.emulateJSON = true;
var Hacker = Backbone.Model.extend({
url:"http://localhost/backbone051/save.php",
});
var hacker = new Hacker();
hacker.set({name:"Herman Ganteng",age:"23"});
hacker.destroy(); //doesn't show any activity :(
Run Code Online (Sandbox Code Playgroud)
您的模型没有Id字段.通常,Id将由先前的提取调用填充.在这个简单的例子中,您可以像这样硬编码:
var Hacker = Backbone.Model.extend({
id: "something",
url:"http://localhost/backbone051/save.php",
});
Run Code Online (Sandbox Code Playgroud)
这将导致在指定的URL处发布POST.