First of all, install the 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 a dependency. After that, you can import the plugins and styles of SemanticUI jQuery into your view model. The view model might be something like this:
import {semanticUI} from 'semantic-ui'; import states from './states-list'; export class States { constructor() { this.states = states;
and then you can display the state list template:
<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>
A few notes. You need to provide the ref attribute to reference the HTMLElement from the view model, so you don't need to hardcode the CSS selector in the VM.
It also looks like Aurelia does not automatically get the correct value after selecting custom semantic drop-down lists. In this case, you can simply update the model manually using the onchange event.
Demo: http://plnkr.co/edit/vJcR7n?p=preview
source share