Bulk removal using trunk

I have a view that contains a list of employees, the end user selects employees and removes employees on more than one.

Each line of the list contains a flag. The end user selects a few flags and clicks the delete button. Selected entries must be deleted.

The MVC controller takes care of the deletion part. Signature of the delete method:

DeleteEmployes(List<int> empIds).

How can i achieve this?

My base model:

var emp = Backbone.Model.extend({
defaults:{
             Id:null,
             fname:null,
             lname:nulll.
}
});
+4
source share
2 answers

, , HTTP DELETE , DeleteEmployes (List empIds). - .

Backbone.Collection.prototype.bulk_destroy = function() {
  var modelId = function(model) { return model.id };
  var ids = this.models.map(modelId);
  // Send ajax request (jQuery, xhr, etc) with the ids attached
  // Empty the collection after the request
  // You may want to include this as a success callback to the ajax request
  this.reset(); 
};
+1

Backbone , . DELETE .

var Employees = new Backbone.Collection([
 { name: 'Employee1' }, 
 { name: 'Employee2' }, 
 { name: 'Employee3' }, 
]);

Employees.each(function(model){
  model.destroy();
});
0

All Articles