Vote count:
0
By a lot of experiments i could bind my first drop down list. So my next step is to select a value of Drop down list. I followed below manner.
<div id="divcountry">
<span>Country </span>
<select data-bind="options: CountriesList,optionsText: 'CountryName',optionsValue:'CountryId',value:CountryId,optionsCaption: 'Select Country..'" style="width: 148px">
</select>
</div>
var countryModel = {
CountriesList: ko.observableArray([])
};
var countryViewModel = function () {
var self = this;
self.CountryModel = countryModel;
// self.validateCountry = ko.validation.group(self.CountryModel, { deep: true });
self.CountriesList = ko.observableArray([]);
self.CountryId = ko.observable();
}
var stateModel = {
StateId: ko.observable(0),
StateName: ko.observable('').extend({ required: true }),
ShortName: ko.observable('').extend({ required: true }),
IsActive: ko.observable(true),
CountryId: ko.observable()
};
var stateViewModel = function () {
var self = this;
self.StateModel = stateModel;
// self.validateState = ko.validation.group(self.CountryModel, { deep: true });
self.StatesList = ko.observableArray([]);
//Handle Submit
self.Submit = function () {
// if (self.validateCountry().length == 0) {
if (self.StateModel.StateId() > 0) {
self.UpdateCountry();
} else {
self.AddState();
}
// self.Reset();
}
// }
Now my doubt is nothing but can we access the countryViewModel data which is "self.CountryId" in my StateModel?? Please i want to send CountryId to the server side code!!
asked 44 secs ago
Aucun commentaire:
Enregistrer un commentaire