Okay, so I'm fairly new to knockout and I've got a good handle on data-bind. However, there's a pattern that another programmer put together and I'm wanting to follow it in the same program just a different form. This is .NET C# MVC5 VMMV. When I use the code written on the other programmer's page everything returns as it should. Mine returns but the data binding isn't working.
both are declared in viewmodel both are called through ajax in model both return data:
This is in the .cshtml file HIS CODE: returns profileData ko.observable and returns the label text
<div class="btn-group margin-top-md pull-right" data-bind="with: profileData">
<label class="btn btn-success btn-xs active" data-bind="text: opportunityName">
</label>
<label class="btn btn-success btn-xs" data-bind="text: status">
</label>
<label class="btn btn-success btn-xs" data-bind="text: strengthIsCustom">
</label>
</div>
MY CODE: returns getContacts ko.observable, populates getContacts but does not return label test.
<div class="btn-group margin-top-md pull-right" data-bind="with: contactData">
<label class="btn btn-success btn-xs active" data-bind="text: TotalPublished">
</label>
<label class="btn btn-success btn-xs" data-bind="text: TotalUnpublished">
</label>
<label class="btn btn-success btn-xs" data-bind="text: TotalContacts">
</label>
</div>
Functions are identical: MINE:
function getContacts() {
model.getContacts().then(function (data) {
contactData({
TotalUnpublished: data.TotalUnpublished,
TotalPublished: data.TotalPublished,
TotalContacts: data.TotalContacts
});
});
}
HIS:
function getProfileData() {
model.getProfileData().then(function (data) {
profileData({
opportunityName: data.OpportunityName,
status: data.OutcomeStatus,
strengthIsCustom: data.Strength.IsCustomalysisStarted)
});
});
}
Does anything stand out here?
data.Strength.IsCustomalysisStarted)
. Have you left some stuff out? – mhucontactData()
defined compared toprofileData()
? – mhu