初始化回调函数
我有一段 jQuery,它使用选择回调。
new Shopify.OptionSelectors("product-variants", {product: product, onVariantSelected: selectCallback}); // initialize multi selector for product
但是,当我尝试使用 jQuery 选择时,它不会初始化回调
$("#product-variants-option-0 option[value=" + selectedVal+"]").attr("selected","selected") ;
I have this piece of jQuery which is using a call back on selection.
new Shopify.OptionSelectors("product-variants", {product: product, onVariantSelected: selectCallback}); // initialize multi selector for product
however when I try to select using jQuery it doesn't initialise the callback
$("#product-variants-option-0 option[value=" + selectedVal+"]").attr("selected","selected") ;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更改代码中的属性不会触发任何回调,有两种方法可以处理它。首先,在设置属性后,您应该自己触发回调,否则您可能需要使用触发函数,而不是尝试更改属性:
甚至模拟单击:
Changing attribute in the code doesn't suppose to fire any callbacks, there are two ways to handle it. First after setting the attribute you should fire he callback yourself or you probably might need to use trigger function instead of trying to change attribute:
or even simulate a click: