This is the error message when IE8 crashes.
Unhandled exception at 0x05A99E34 (mshtml.dll) in iexplore.exe: 0xC0000005: Access violation reading location 0x0000003C.
the following works.
<tbody data-bind="foreach: searchResults">
<tr><td data-bind="text: orgName"></td></tr>
</tbody>
but the following crash on IE8 (works on IE10, FF and Chrome).
orgName
is just a string set in the vm.searchStakeholder
.
Here's more about the view model.
var Stakeholder = (function () {
function Stakeholder(orgName) {
this.orgName = ko.observable(orgName);
};
return Stakeholder;
})();
var vm = new function () {
var self = this;
self.searchResults = ko.observableArray();
self.searchStakeholder = function (){
$.ajax({
type:'get',
dataType: 'json',
url: 'the-url',
contentType: 'application/json',
success: function(json){
for(var i = 0; i < json.SearchResults.length; i++) {
var x = json.SearchResults[i];
self.searchResults.push(new Stakeholder(x.orgName));
}
}
});
};
});
ko.applyBindings(vm, $('#divMyApp')[0]);
Assuming that you are getting some results back of type Stakeholder and storing them in searchResults -
<table data-bind="with: searchResults">
<th><tr>
<td>Name</td>
<td>Org Name</td>
</tr></th>
<tr data-bind="foreach: stakeholder">
<td data-bind="text: name"></td>
<td>
<input type="text" data-bind="value: orgName" />
</td>
</tr>
</table>
Works in IE8. But since your searchResults is a KO.observableArray() I assume that you need to foreach your searchResults, but without a better picture of what you are doing it's hard to tell, here that is anyway.
<table>
<th><tr>
<td>Name</td>
<td>Org Name</td>
</tr></th>
<tr data-bind="foreach: searchResults">
<td data-bind="text: name"></td>
<td>
<input type="text" data-bind="value: orgName" />
</td>
</tr>
</table>
I also can't tell what orgName is or how it is being passed to the constructor of the Stakeholder, if it is a KO.observable then remove it as a parameter and use orgName(), if it is a parameter being passed in then move it up to the parent function and rename it to ensure it isn't a circular reference.
var Stakeholder = (function (organizationName) {
var self = this;
function Stakeholder() {
this.orgName = ko.observable(self.organizationName);
};
return Stakeholder;
})();
Last, not sure what the 'blah' element is at the bottom, maybe just a copy pasta typo?
User contributions licensed under CC BY-SA 3.0