I’m exploring backbone.js framework and I’m interested how can I fetch collection’s model from a js object. Let’s say I have the following simple application.
<html>
<head>Backbone.js</head>
<body>
<script type="text/javascript">
var data = [{id:1, name: 'Erik'}, {id:2, name: 'John'}]
</script>
<script type="text/javascript">
var Data = Backbone.model.extend({});
var Datas = Backbone.Collection.extend({
model: Data
});
</script>
</body>
</html>
So how can initialize ‘Datas’ collection from the ‘data’ object?
see below: