model = new Backbone.Model({
data:[
{text:'Google',href:'https://www.google.co.id'},
{text:'Facebook',href:'https://www.facebook.com'},
{text:'Twitter',href:'https://www.twitter.com'},
{text:'Youtube',href:'https://www.youtube.com'}
]
});
var View = Backbone.View.extend({
initialize:function(){
//console.log(this.options.blankOption);
//memanggil blankOption
this.template = $('#listtemplate').children();
},
el:$('#container'),
events:{
//'eventName selectorName':'functionName' -->that will call
'click button':'render'
},
render: function(){
var data = this.model.get('data');
for(var i=0, a = data.length ; i<a; i++){
var li =this.template.clone().find('a').attr('href',data[i].href).text(data[i].text).end();
this.el.find('ul').append(li);
}
}
//if you use el:'#container' call with this.$el or $(this.el)
});
//var view = new View({blankOption:"iki isine blankoptions mas"});
//var view = new View({el:document.getElementById('container') });
//or var view = new View({el:$('#container') });
//var view = new View({tagName,className,id,attributes });
//property that you can use
var view = new View({model:model});
//el is DOM element
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.