I have rewritten backbone sync's destroy () to PHP (click the Delete button will trigger the Delete event), in PHP to implement the deletion of the data, but because collection defined the URL, when rewriting the destroy URL, Unable to perform the appropriate action, ask for answers!
//CollectionApp.Users=Backbone.Collection.extend({ model : App.User, url : function(){ return '/crud2/save.php'; }, initialize : function(){ this.on('add',function(){ console.log(this.length); }); this.on('remove',function(){ console.log(this.length); }); }});
`delete : function(){ //this.model.url='delete.php'; //console.log(this.model.url); $('#Name').val(""); $('#Phone').val(""); this.model.destroy({ url : 'delete.php', type : 'POST', success : function(){ console.log('success'); }, error : function(){ console.log('error'); } } ); }`
//delete.php
username); $sql = "delete from user where username == '$data->username'"; mysql_query($sql);?>
Reply content:
I have rewritten backbone sync's destroy () to PHP (click the Delete button will trigger the Delete event), in PHP to implement the deletion of the data, but because collection defined the URL, when rewriting the destroy URL, Unable to perform the appropriate action, ask for answers!
//CollectionApp.Users=Backbone.Collection.extend({ model : App.User, url : function(){ return '/crud2/save.php'; }, initialize : function(){ this.on('add',function(){ console.log(this.length); }); this.on('remove',function(){ console.log(this.length); }); }});
`delete : function(){ //this.model.url='delete.php'; //console.log(this.model.url); $('#Name').val(""); $('#Phone').val(""); this.model.destroy({ url : 'delete.php', type : 'POST', success : function(){ console.log('success'); }, error : function(){ console.log('error'); } } ); }`
//delete.php
username); $sql = "delete from user where username == '$data->username'"; mysql_query($sql);?>