I am trying to use bootstrap with a nicely styled knockout button dropdown . Unfortunately, dropdowns are created using links, not <select>
, and knockout-bootstrap has no handlers to help.
I managed to get all the styles to work (button type, icons, selected / canceled). But I still can't get the click function to work:
JS script example
<div class="btn-group"> <button type="button" class="btn btn-small dropdown-toggle" data-bind="css: {'btn-default' : status().statusName=='Matched', 'btn-danger' : status().statusName=='None', 'btn-info' : status().statusName=='Set'}" data-toggle="dropdown"> <span class="glyphicon" data-bind="css: {'glyphicon-ok' : status().statusName=='Matched', 'glyphicon-remove' : status().statusName=='None', 'glyphicon-list' : status().statusName=='Set'}"></span> <span data-bind="text: status().statusName"> </span> <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu" data-bind="foreach: $root.availableStatus"> <li data-bind="css: {'disabled' : statusName==$parent.status().statusName}"> <a href="#" data-bind="click: $root.updateStatus"><span class="glyphicon" data-bind="css: {'glyphicon-ok' : statusName=='Matched', 'glyphicon-remove' : statusName=='None', 'glyphicon-list' : statusName=='Set'}"></span> <span data-bind="text: statusName"></span></a>]
source share