mirror of
https://github.com/Ekokumppanit/Lentolaskuri.git
synced 2026-02-18 04:48:33 +00:00
Initial commit
This commit is contained in:
29
app/scripts/views/leg.js
Normal file
29
app/scripts/views/leg.js
Normal file
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
define([
|
||||
'backbone',
|
||||
'Template'
|
||||
], function (Backbone, Template) {
|
||||
var LegView = Backbone.View.extend({
|
||||
tagName: 'div',
|
||||
className: 'leg',
|
||||
events: {
|
||||
'click a.delete': 'destroy'
|
||||
},
|
||||
initialize: function () {
|
||||
this.model.on('change', this.render, this);
|
||||
this.model.on('destroy', this.remove, this);
|
||||
},
|
||||
destroy: function () {
|
||||
this.model.destroy();
|
||||
},
|
||||
render: function () {
|
||||
this.$el.data('id', this.model.get('id'));
|
||||
this.$el.attr('id', 'leg-' + this.model.get('id')); // fuu
|
||||
this.$el.html(Template.leg(this.model.toJSON()));
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
return LegView;
|
||||
});
|
||||
Reference in New Issue
Block a user