Currently using msDropDown 3.2 to make controls look pretty, however due to the nature of the application being developed, I have looked into using Knockout JS to handle UI-Data Binding. Unfortunately, whenever I change the property on the view model it is changing the select but not the rendered control (I know the code required to change the rendered control, but am not sure on how to hook this into Knockout).
Has anybody integrated these two tools, and if so then how did you get them to play nicely together?
Edit:
HTML:
<select data-bind="value: Type">
<option value="1">First</option>
<option value="2">Second</option>
<option value="3">Third</option>
<option value="4">Fourth</option>
</select>
JavaScript:
function ViewModel() {
var self = this;
self.Name = ko.observable();
self.Type = ko.observable();
self.IsVisible = ko.computed(function () {
return this.Type() == 1;
}, this);
}
var vm = new ViewModel();
ko.applyBindings(vm);
$(document).ready(function () {
$("select").msDropDown();
});
As you can see from the above code, I am creating a ViewModel instance, then applying the bindings and initiating msDropDown.
If I was to then call the following:
vm.Type("2");
Then it will update the underlying select, but not the front end of the msDropDown control. Basically need a way to hook into an event that Knockout may call when changing a property so that I can determine if it's a select and call some msDropDown specific code to update the UI.
Thanks,
Chris.