TypeScript -使用knockout.js的JavaScript在IE8中无法工作- Object不支持此属性或
TypeScript - JavaScript using knockout.js not working in IE8 - "Object doesn't support this property or method"
我有这个代码(也显示在下面),这是给我一个错误在IE8,但在Chrome和PhantomJS很好。
错误是"对象不支持此属性或方法knockout-2.2.1.debug.js,第2319行字符35",从currentPage(pages[pages.indexOf(current) + steps]);
我不知道为什么它不工作,所以任何帮助将非常感激!
var Page = (function () {
function Page(index, name, canNavigateToPage, navigatedToThisPage) {
this.index = index;
this.name = name;
this.canNavigateToPage = canNavigateToPage;
this.navigatedToThisPage = navigatedToThisPage;
}
Page.prototype.navigateToPage = function () {
if (this.canNavigateToPage()) {
this.navigatedToThisPage(this);
}
};
return Page;
})();
var AccountSearchParameters = (function () {
function AccountSearchParameters() {
this.reference = ko.observable();
this.scheme = ko.observable();
this.lastName = ko.observable();
this.sufficientInputToSearchForAccount = ko.computed(function () {
return this.reference() && this.scheme() && this.lastName();
}, this);
}
return AccountSearchParameters;
})();
function viewModel() {
var self = this,
currentPage = ko.observable(),
accountSearchParameters = new AccountSearchParameters(),
forwardPageProgressionGuards = {
'1': function canMoveToPage2() {
return accountSearchParameters.sufficientInputToSearchForAccount();
},
'2': function canMoveToPage3() {
return true;
},
'3': function canMoveToPage4() {
return true;
}
},
canMoveToNextPage = function (currentlyOnPage) {
function disallowPageMovementNotExplicitlyDefined() {
return false;
}
return (forwardPageProgressionGuards[currentlyOnPage] || disallowPageMovementNotExplicitlyDefined)();
},
canMoveToPreviousPage = function (currentlyOnPage) {
return currentlyOnPage > 1;
},
pages = [
new Page(1, 'Customer details', function () {
return true;
}, function (page) {
currentPage(page);
}),
new Page(2, 'Bank details', forwardPageProgressionGuards['1'], currentPage),
new Page(3, 'Payment details', forwardPageProgressionGuards['2'], currentPage),
new Page(4, 'Confirmation', function () {
return true;
}, currentPage)],
pageNavigator = function (canNavigate, steps) {
current = currentPage();
console.log(canNavigate(current.index));
if (canNavigate(current.index)) {
currentPage(pages[pages.indexOf(current) + steps]);
}
};
currentPage(pages[0]);
self.page = ko.computed(function () {
return currentPage();
});
self.accountSearchParameters = accountSearchParameters;
self.nextPage = function () {
pageNavigator(canMoveToNextPage, 1);
};
self.previousPage = function () {
pageNavigator(canMoveToPreviousPage, -1);
};
self.canMoveToNext = ko.computed(function () {
return canMoveToNextPage(currentPage().index);
});
return self;
}
$(function () {
ko.applyBindings(viewModel());
});
indexOf在IE8中不支持,使用$.inArray
相关文章:
- Javascript:selenium Web驱动程序isDisplayed()不工作
- 如何在jquery中为object键创建一个工作变量以避免额外的代码
- 有人可以解释一下Object.defineProperty如何在javascript的构造函数中工作
- Prototype 1.7 Object.extend 在原型类中使用时无法正常工作
- Angular 2:{{object}}工作,{{object.child}}}抛出错误
- Object.assign未按预期工作
- Object.keys(obj)的工作方式
- node.js不能工作Object.keys
- TypeScript -使用knockout.js的JavaScript在IE8中无法工作- Object不支持此属性或
- slideUp不能在有效的jQuery-Object上工作
- 当返回object'的值时,括号符号是如何工作的?
- fanybox不能在IE中工作:object不支持此方法
- 为什么object[undefined]不能在javascript中工作?
- 原型链中的函数解析将如何为Object.prototype作为构造函数工作
- 不能't get jtree工作- "Uncaught TypeError: Object #
- Javascript: object属性是数组,但是追加是不工作的
- JavaScript' in object特性是如何工作的?
- Javascript: object[method]()不工作或如何为纯Javascript代码构建jQuery插件
- JavaScript继承Object.create()未按预期工作
- jQuery和object literal函数不能一起工作