not sure missing here, silly, unable find regarding, let's how use bootstrap-select control in aurelia views. can point me right article please? ps: not looking create custom control out of bootstrap-select use as. request help. https://silviomoreto.github.io/bootstrap-select/
you can create custom attribute adds bootstrap-select behavior <select>
element. here's example:
http://plnkr.co/edit/so23hm?p=preview
bootstrap-select.js
import {inject} 'aurelia-framework'; const defaultoptions = { style: 'btn-info', size: 4 }; @inject(element) export class bootstrapselectcustomattribute { constructor(element) { this.element = element; } attached() { let options = object.assign({}, defaultoptions, this.value || {}); $(this.element).selectpicker(options); } detached() { $(this.element).selectpicker('destroy'); } }
app.html:
<template> <require from="./bootstrap-select"></require> <select value.bind="selectedplanet" bootstrap-select> <option model.bind="null">select planet</option> <option repeat.for="planet of planets" model.bind="planet">${planet.name}</option> </select> </template>
app.js:
export class app { selectedplanet = null; planets = [ { name: 'mercury', diameter: 3032 }, { name: 'venus', diameter: 7521 }, { name: 'earth', diameter: 7926 }, { name: 'mars', diameter: 4222 }, { name: 'jupiter', diameter: 88846 }, { name: 'saturn', diameter: 74898 }, { name: 'uranus', diameter: 31763 }, { name: 'neptune', diameter: 30778 }]; }
pass options selectpicker
call this:
<select bootstrap-select.bind="{ size: 4 }">
or this:
<select bootstrap-select.bind="myoptions"> <!-- assumes there's myoptions property on view-model -->
Comments
Post a Comment