Backbone Relational Template
Underscore, Backbone, Backbone-relational for http://stackoverflow.com/questions/10698737/addmodels-not-triggered-backbone-relational
by edwardmsmith
HTML
<script src="https://raw.github.com/documentcloud/underscore/master/underscore-min.js"></script>
<script src="https://raw.github.com/documentcloud/backbone/master/backbone-min.js"></script>
CoffeeScript
class PokerRange extends Backbone.Model
defaults:
id:0
cards:[[0..12],[0..12],[0..12],[0..12],[0..12],[0..12],[0..12],[0..12],[0..12],[0..12],[0..12],[0..12],[0..12]]
validate: (attributes) ->
console.log "validate: #{attributes}"
if attributes.id<0 then "id should be positive"
window.firstrange= new PokerRange id:5
console.log window.firstrange.toJSON()
window.firstrange.set("id",-4,{validate:true})
console.log window.firstrange.toJSON()