Jquery 删除之前的敲除返回textNode而不是elementNode
当使用Knockout的foreach绑定时,我试图在列表中添加项目时复制分类黄色fadein。(来自) 这是我的密码Jquery 删除之前的敲除返回textNode而不是elementNode,jquery,knockout.js,Jquery,Knockout.js,当使用Knockout的foreach绑定时,我试图在列表中添加项目时复制分类黄色fadein。(来自) 这是我的密码 <div id="minicartItems" data-bind="template: { foreach: DisplayItems, beforeRemove: ElementFadeOut, afterAdd: ElementFadeIn }"> <div data-bind="attr: { id: 'sideCartItm' + $
<div id="minicartItems" data-bind="template: { foreach: DisplayItems, beforeRemove: ElementFadeOut, afterAdd: ElementFadeIn }">
<div data-bind="attr: { id: 'sideCartItm' + $index() }">
<!-- ko if: IsFleet() -->
<!-- DO STUFF -->
<!-- /ko -->
<!-- ko ifnot: IsFleet() -->
<!-- DO STUFF -->
<!-- /ko -->
</div>
</div>
但是,在添加或删除项目时,控制台上会出现错误(并且不会出现褪色)
jquery-1.8.3.min.js:2 Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.
at Dt (jquery-1.8.3.min.js:2)
at Function.css (jquery-1.8.3.min.js:2)
at Gt (jquery-1.8.3.min.js:2)
at Object.Gn (jquery-1.8.3.min.js:2)
at Kn (jquery-1.8.3.min.js:2)
at Text.o (jquery-1.8.3.min.js:2)
at Function.dequeue (jquery-1.8.3.min.js:2)
at Text.<anonymous> (jquery-1.8.3.min.js:2)
at Function.each (jquery-1.8.3.min.js:2)
at init.each (jquery-1.8.3.min.js:2)
jquery-1.8.3.min.js:2未捕获类型错误:未能在“窗口”上执行“getComputedStyle”:参数1不是“元素”类型。
在Dt(jquery-1.8.3.min.js:2)
在Function.css(jquery-1.8.3.min.js:2)
at Gt(jquery-1.8.3.min.js:2)
在Object.Gn(jquery-1.8.3.min.js:2)
在Kn时(jquery-1.8.3.min.js:2)
在Text.o(jquery-1.8.3.min.js:2)
在Function.dequeue(jquery-1.8.3.min.js:2)
在文本中
如果我展开parentNode
,然后展开子节点
,我可以看到有text和div节点,但我不确定为什么
如何获得发送元素节点而不是文本节点的函数?使用afterRender
而不是afterAdd
是解决方案-在呈现DOM元素之前无法添加它们你不会把整个列表淡入或者每个列表项目吗?考虑使用SeaRebug,然后元素可能在那里。
jquery-1.8.3.min.js:2 Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.
at Dt (jquery-1.8.3.min.js:2)
at Function.css (jquery-1.8.3.min.js:2)
at Gt (jquery-1.8.3.min.js:2)
at Object.Gn (jquery-1.8.3.min.js:2)
at Kn (jquery-1.8.3.min.js:2)
at Text.o (jquery-1.8.3.min.js:2)
at Function.dequeue (jquery-1.8.3.min.js:2)
at Text.<anonymous> (jquery-1.8.3.min.js:2)
at Function.each (jquery-1.8.3.min.js:2)
at init.each (jquery-1.8.3.min.js:2)