mirror of
https://github.com/Ekokumppanit/Lentolaskuri.git
synced 2026-01-26 11:13:58 +00:00
40 lines
869 B
JavaScript
40 lines
869 B
JavaScript
'use strict';
|
|
|
|
define([
|
|
'backbone',
|
|
'models/leg',
|
|
'views/dropdown',
|
|
'libs/airports',
|
|
'Template'
|
|
], function (Backbone, Leg, Dropdown, airports, Template) {
|
|
var LegInput = Backbone.View.extend({
|
|
el: '.legInputWidget',
|
|
events: {
|
|
'click button': 'openDropdown'
|
|
},
|
|
initialize: function () {
|
|
this.dropdown = new Dropdown({
|
|
el: this.$el.find('input'),
|
|
select2: {
|
|
initSelection: airports.airportById,
|
|
formatResult: Template.choice,
|
|
formatSelection: Template.choice,
|
|
minimumInputLength: 1,
|
|
ajax: airports.ajax
|
|
}
|
|
});
|
|
|
|
this.dropdown.bind('new-leg', this.newLeg, this);
|
|
},
|
|
openDropdown: function () {
|
|
this.dropdown.open();
|
|
},
|
|
newLeg: function (data) {
|
|
this.collection.push(new Leg(data));
|
|
}
|
|
});
|
|
|
|
return LegInput;
|
|
});
|
|
|