【发布时间】:2018-12-23 23:14:09
【问题描述】:
我使用的代码是这样的:
jQuery(document).ready(function($){
if(window.location.href =='https://mysite/csproduct/vproducts/new/set/4/type/simple/'){
console.log('ready');
$("[name='product[vendor_price]']").keyup(function() {
$("[name='product[price]']").val($(this).val()).change();
});
}
});
如果我将代码粘贴到控制台中,它可以工作。
即使没有粘贴我得到的代码
console.log - 准备好了。
除此之外,控制台没有错误。
这里使用的HTML是这样的:
<div class="admin__field _required" data-bind="css: $data.additionalClasses, attr: {'data-index': index}, visible: visible" data-index="vendor_price">
<label class="admin__field-label" data-bind="attr: {for: uid}, visible: $data.labelVisible" for="CTK9J41">
<span data-bind="attr: {'data-config-scope': $data.scopeLabel}, text: label" data-config-scope="[STORE VIEW]">Vendor Price</span>
</label>
<div class="admin__field-control" data-bind="css: {'_with-tooltip': $data.tooltip, '_with-reset': $data.showFallbackReset && $data.isDifferedFromDefault}">
<input class="admin__control-text" type="text" data-bind="
event: {change: userChanges},
value: value,
hasFocus: focused,
valueUpdate: valueUpdate,
attr: {
name: inputName,
placeholder: placeholder,
'aria-describedby': noticeId,
id: uid,
disabled: disabled
}" name="product[vendor_price]" aria-describedby="notice-CTK9J41" id="CTK9J41">
</div>
</div>
<div class="admin__field admin__field-small _required" data-bind="css: $data.additionalClasses, attr: {'data-index': index}, visible: visible" data-index="price">
<span data-bind="attr: {'data-config-scope': $data.scopeLabel}, text: label" data-config-scope="[STORE VIEW]">Price</span>
</label>
<div class="admin__field-control" data-bind="css: {'_with-tooltip': $data.tooltip, '_with-reset': $data.showFallbackReset && $data.isDifferedFromDefault}">
<div class="admin__control-addon">
<input class="admin__control-text" type="text" data-bind="
event: {change: userChanges},
value: value,
hasFocus: focused,
valueUpdate: valueUpdate,
attr: {
name: inputName,
placeholder: placeholder,
'aria-describedby': noticeId,
id: uid,
disabled: disabled
}" name="product[price]" aria-describedby="notice-JHLHU2O" id="JHLHU2O">
<label class="admin__addon-prefix" data-bind="attr: {for: uid}" for="JHLHU2O">
<span data-bind="text: addbefore">₹</span>
</label>
</div>
</div>
【问题讨论】:
-
那么什么是不工作?您能否提供随附的 HTML,以便我们重现问题?
-
当然我会添加 html,尽管 magento 生成的复杂度并不高。什么不起作用 - 当我在字段
vendor-price中输入时,应该将其复制到product-price -
我在您的 HTML 中没有看到任何字段
vendor_price...。确实 存在的是artist_price。也许有一个混乱? -
是的,实际上我已经用供应商价格替换了艺术家价格,现在我已经在问题中替换了。