Created
June 29, 2011 18:40
-
-
Save KarlHerler/1054545 to your computer and use it in GitHub Desktop.
Trivial views with Backbone makes me all happy inside
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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