Backbone.js collectin lance o erro
Eu sou (como iniciante) fazendo uma pequena função de backbone para anexar meus links, para isso eu usando a coleção para ser designada como modelo,
Mas a coleção joga o erro .. qualquer um pode corrigir meu código por favor?
$(function(){
var Model = new Backbone.Model({
data:[
{name:'Yahoo',href:'http://www.yahoo.com'},
{name:'Gmail',href:'http://www.gmail.com'},
{name:'Bing',href:'http://www.bing.com'}
]
});
var Collection = new Backbone.Collection.extend({
model:Model // is this not correct way to do?
});
var View = Backbone.View.extend({
el:'#container',
events:{
'click button':'render'
},
initialize:function(){
this.collection = new Collection(); //throw the error!
this.template = $('#temp').children();
},
render:function(){
var data = this.collection.get('data');
for(i=0;i<data.length;i++){
var li = this.template.clone().find('a')
.attr('href',data[i].href)
.text(data[i].name).end();
this.$el.find('ul').append(li);
}
}
});
var myLink = new View();
})