An open API service indexing awesome lists of open source software.

https://github.com/akiomik/backbone-batch-operations

batch operation plugin for backbone.js
https://github.com/akiomik/backbone-batch-operations

Last synced: 2 months ago
JSON representation

batch operation plugin for backbone.js

Awesome Lists containing this project

README

        

backbone-batch-operations
==========================
This is a backbone.js plugin provides batch operations.

## Installation

Install with Bower:

```bash
bower install backbone-batch-operations
```

Add following line to your html.

```html

```

## Sample

```javascript
var Document = Backbone.Model.extend({});
var Documents = Backbone.BatchCollection.extend({
model: Document,
url: 'http://example.com'
});
var docs = new Documents({});

// Insert
var models = [
{'some': 'data'}
];
docs.add(models, {silent: true});
docs.save(); // POST

// Update
docs.each(function(doc) {
var json = doc.toJSON();
json.some = 'data was modified';
doc.set(json, {silent: true});
});
docs.save(); // PUT

// Delete
var models = docs.models;
docs.remove(models, {silent: true});
docs.save(); // PUT
```

## Reference
### collection.save([options]);

### collection.isNew();

### collection.isChanged();

## License
The MIT License. See `LICENSE` file.