First of all, install SemanticUI package. With JSPM run this line to install it from Github:
jspm install semantic-ui=github:Semantic-Org/Semantic-UI
It will also install jQuery as dependency. After that you will be able to import SemantinUI's jQuery plugins and styles into your view-model. View-model can be something like this then:
import {semanticUI} from 'semantic-ui';
import states from './states-list';
export class States {
constructor() {
this.states = states; // or load states with http-client, etc.
}
attached() {
$(this.statesSelect).dropdown().on('change', e => {
this.stateSelected = e.target.value;
});
}
}
and then you can render template with states list:
<template>
<p>Selected: ${stateSelected}</p>
<select ref="statesSelect" value.bind="stateSelected" class="ui search dropdown">
<option value="">State</option>
<option value="${state.code}"
model.bind="state.name"
repeat.for="state of states">${state.name}</option>
</select>
</template>
Couple of notes. You need to provide ref attribute to reference HTMLElement from view-model, this way you don't have to hardcode CSS selectors into VM.
Also looks like Aurelia doesn't pick up proper value automatically after custom Semantic dropdown changes selection. In this case you can simply update model manually with onchange event.
Demo: http://plnkr.co/edit/vJcR7n?p=preview