mirror of
https://github.com/Ekokumppanit/Lentolaskuri.git
synced 2026-02-12 02:46:18 +00:00
Initial commit
This commit is contained in:
39
app/scripts/views/leginput.js
Normal file
39
app/scripts/views/leginput.js
Normal file
@@ -0,0 +1,39 @@
|
||||
'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;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user