<require from="...."></require>
- . - , . <require from="select2/js/select2.min.js"></require>
, aurelia , . , .../select2.min.html
"aurelia way" select2 , select2 . - :
Select2--attribute.js
import {customAttribute, inject} from 'aurelia-framework';
import {DOM} from 'aurelia-pal';
import $ from 'jquery';
import 'select2';
import 'select2/css/select2.min.css!'
@customAttribute('select2')
@inject(Element)
export class Select2CustomAttribute {
constructor(element) {
this.element = element;
}
attached() {
$(this.element)
.select2(this.value);
}
detached() {
$(this.element).select2('destroy');
}
}
:
app.html
<require from="select2-custom-attribute"></require>
<select select2 value.bind="selectedState">
<option repeat.for="state of states" model.bind="state">${state.name}</option>
</select>
, select2 ( , "options", select2, ):
app.html
<require from="select2-custom-attribute"></require>
<select select2.bind="options" value.bind="selectedState">
<option repeat.for="state of states" model.bind="state">${state.name}</option>
</select>
: https://gist.run/?id=0137059e029fc4b3ccd367e385f47b19
, select2 jspm, . , , select2, select2 js css script/link .