mirror of
https://github.com/Ekokumppanit/Lentolaskuri.git
synced 2026-01-26 11:13:58 +00:00
30 lines
672 B
JavaScript
30 lines
672 B
JavaScript
'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;
|
|
});
|