开发者

Initialise call back function

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") ; 


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:

 $( "radio-button-selector").trigger( "select");

or even simulate a click:

 $( "radio-button-selector").trigger( "click");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜