【发布时间】:2017-07-14 23:54:25
【问题描述】:
我不知道它是否特定于 Magento 2,但是一个已经设置的带有 jQuery change 事件的 HTML 节点在带有附加 VM 的淘汰组件中运行时将丢失其 change 事件(查看模型)。
Magento 中的情况:
我通过布局 xml 将 product options wrapper 移动到自定义块中
<referenceBlock name="product.info.form.options">
// Custom block definition
<move element="product.info.options.wrapper" destination="custom.block" />
</referenceBlock>
没有任何问题!
现在,当用 Magentos custom "scope" binding 围绕这个移动块包装一个淘汰模型时,所有应用的 onChange 事件都将被删除 - 这意味着在这种情况下,可配置选项选择框保持禁用状态。
change 事件正在被应用 here in configurable.js
$(element).on('change', this, this._configure);
.. 这对我来说似乎也适合如何添加事件。
因此,在我的模板文件中,我执行以下操作来围绕这个 html sn-p 包装我的淘汰组件(带有附加的 VM):
<div class="tab-content" data-step="1" data-bind="scope:'times'">
// all change events are removed from the configurable widget
<?php echo $block->getChildHtml('product_options_wrapper'); ?>
</div>
有人知道这是 KnockoutJS 和 jQuery 之间的问题,还是与 Magento 有关?
更新:
这似乎是 Magento 中的一个错误: https://github.com/magento/magento2/issues/10261
【问题讨论】:
标签: jquery magento knockout.js magento2