<commit_before># Signal Box Backbone SDK

The Signal Box Backbone SDK provides support for storing Backbone model data in Signal Box by overriding `Backbone.sync`.

The sync implementation relies heavily on the [Signal Box JavaScript SDK](https://github.com/signalbox/sdk-javascript#readme) and uses `jQuery.ajax`.

You'll need [an account](https://manage.getsignalbox.com/sign-up) to communicate with Signal Box. More information can be found on [the Signal Box documentation site](https://docs.getsignalbox.com).


## Contents

* [Setup](#setup)
* [Collections](#collections)
* [Models](#models)


## Setup

Include the SDK and it's dependencies in your page:

```html
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js"></script>
<!-- Add these below -->
<script type="text/javascript" src="http://cdn.getsignalbox.com/sdks/javascript/sdk-0.2.1.js"></script>
<script type="text/javascript" src="http://cdn.getsignalbox.com/sdks/backbone/sdk-0.1.0.js"></script>
```

Be sure to call [`SignalBox.setup`](https://github.com/signalbox/sdk-javascript#setup) before making any calls:

```javascript
SignalBox.setup({
  app      : 'bookmarks',
  username : 'demo'
});
```


## Collections

To create a collection, extend `SignalBox.Backbone.Collection`:

```javascript
var Bookmarks = SignalBox.Backbone.Collection({
  resource : 'bookmarks'
});

Bookmarks.fetch({
  success : function(collection){
    console.log("success: " + collection.length + " records found.");
  }
})
```

The options hash supports any options available with [`SignalBox.list`](https://github.com/signalbox/sdk-javascript#list). If you'd prefer not to extend `SignalBox.Backbone.Collection` you will need to include the `parse` implementation provided with the SDK.


## Models

To create a model, extend `SignalBox.Backbone.Model`:
<commit_msg>Fixed typo in readme regarding collections.<commit_after># Signal Box Backbone SDK

The Signal Box Backbone SDK provides support for storing Backbone model data in Signal Box by overriding `Backbone.sync`.

The sync implementation relies heavily on the [Signal Box JavaScript SDK](https://github.com/signalbox/sdk-javascript#readme) and uses `jQuery.ajax`.

You'll need [an account](https://manage.getsignalbox.com/sign-up) to communicate with Signal Box. More information can be found on [the Signal Box documentation site](https://docs.getsignalbox.com).


## Contents

* [Setup](#setup)
* [Collections](#collections)
* [Models](#models)


## Setup

Include the SDK and it's dependencies in your page:

```html
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js"></script>
<!-- Add these below -->
<script type="text/javascript" src="http://cdn.getsignalbox.com/sdks/javascript/sdk-0.2.1.js"></script>
<script type="text/javascript" src="http://cdn.getsignalbox.com/sdks/backbone/sdk-0.1.0.js"></script>
```

Be sure to call [`SignalBox.setup`](https://github.com/signalbox/sdk-javascript#setup) before making any calls:

```javascript
SignalBox.setup({
  app      : 'bookmarks',
  username : 'demo'
});
```


## Collections

To create a collection, extend `SignalBox.Backbone.Collection`:

```javascript
var Bookmarks = SignalBox.Backbone.Collection({
  resource : 'bookmarks'
});

var collection = new Bookmarks;

collection.fetch({
  success : function(collection){
    console.log("success: " + collection.length + " records found.");
  }
})
```

The options hash supports any options available with [`SignalBox.list`](https://github.com/signalbox/sdk-javascript#list). If you'd prefer not to extend `SignalBox.Backbone.Collection` you will need to include the `parse` implementation provided with the SDK.


## Models

To create a model, extend `SignalBox.Backbone.Model`:

{'fraction_non_alphanumeric': 0.15350467289719627, 'fraction_numerical': 0.007009345794392523, 'mean_word_length': 4.954102920723226, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1236743', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1277, 'n_words': 329}