Skip to content

Instantly share code, notes, and snippets.

@KarlHerler
Created June 29, 2011 18:40
Show Gist options
  • Save KarlHerler/1054545 to your computer and use it in GitHub Desktop.
Save KarlHerler/1054545 to your computer and use it in GitHub Desktop.
Trivial views with Backbone makes me all happy inside
var Flags = Backbone.View.extend({
el: $('#main'),
initialize: function() {
_.bindAll(this, 'render');
this.render();
},
render: function() {
var append="";
append += '<div id="flag-0" class="one smaller"></div><div id="flag-1" class="two smaller"></div>'
append += '<div id="flag-2" class="three smaller"></div>'
append += '<div id="flag-3" class="four smaller"></div><div id="flag-4" class="five smaller"></div>'
$(this.el).append(append)
},
setPosition: function(i, x, y) {
$("#flag-"+i).css('left', x);
$("#flag-"+i).css('top', y);
},
show: function(i) {
$("#flag-"+i).css('display', 'block');
},
move: function(i, x, y) {
this.setPosition(i, x ,y);
this.show(i);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment