gpt4 book ai didi

knockout.js - 未捕获的类型错误 : Cannot read property 'nodeType' of undefined on ko. cleanNode

转载 作者:行者123 更新时间:2023-12-05 01:02:35 33 4
gpt4 key购买 nike

  var ready;

ready = function() {
var imageChooser, productChooser;
productChooser = function() {
var self;
self = this;
self.quantityId = ko.observable(1);
self.quantityText = ko.observable('QTY');
self.genderId = ko.observable(1);
self.sizeId = ko.observable(1);
self.colorId = ko.observable(1);
self.fullSize = ko.observable('SIZE');
this.setGenderAndSize = function(stringtoparse, thestring) {
var values;
values = stringtoparse.split(":");
self.fullSize("SIZE: " + thestring);
self.genderId(values[0]);
self.sizeId(values[1]);
};
this.setQuantity = function(quantity) {
self.quantityId(quantity);
self.quantityText("QTY: " + quantity);
};
};
imageChooser = function() {
this.clicked = ko.observable();
this.setBigImage = (function(message) {
alert(message);
}).bind(this);
};
ko.applyBindings(new productChooser(), $("#genderAndSizeChooser")[0]);
ko.cleanNode($('#genderAndSizeChooser')[0]);
return ko.applyBindings(new imageChooser(), $('#imageChooser')[0]);
};

$(document).on('ready page:load', ready);

我目前有这个代码。不知何故, ko.cleanNode代码:
ko.cleanNode($('#genderAndSizeChooser')[0]);

产生错误:
Uncaught TypeError: Cannot read property 'nodeType' of undefined

有人知道错误的原因吗?

最佳答案

看起来它实际上没有找到 ID 为 genderAndSizeChooser 的元素.
ko.applyBindings电话将收到 undefined并像往常一样将绑定(bind)应用到正文,这样就不会出错,但调用 ko.cleanNodeundefined会导致错误。

关于knockout.js - 未捕获的类型错误 : Cannot read property 'nodeType' of undefined on ko. cleanNode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26052423/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com