
Untitled
By: a guest on
May 2nd, 2012 | syntax:
None | size: 1.00 KB | hits: 16 | expires: Never
KnockoutJs Observable Arrays and Dropdownlists
<script type="text/javascript">
$(document).ready(function () {
var sampleSubmission = function () {
this.selectedPlatform = ko.observable();
this.platforms = ko.observableArray();
this.showSearch = ko.observable(false);
this.craftText = ko.observable();
this.showSerialNumber = ko.observable(0);
this.selectedPlatform.subscribe(function (platformId) {
} .bind(this));
};
var sampleSubmissionViewModel = new sampleSubmission();
ko.applyBindings(sampleSubmissionViewModel);
//Load the platforms
$.ajax({
url: '@Url.Action("GetPlatforms", "Home")',
type: 'GET',
success: function (data) {
sampleSubmissionViewModel.platforms(data);
}
});
});
</script>
<select data-bind="options: platforms, value: selectedPlatform, optionsText: 'name'"></select>