Select default options when switching top level categories to avoid having empty product preview
var cpbLoaded = function() { if (jQuery('#react-tabs-2').length > 0) { moduleApp.init(); } else { window.requestAnimationFrame(cpbLoaded); } }; cpbLoaded(); var $document, $root; var moduleApp = { init: function () { this.initGlobals(); this.handleOptions(); }, initGlobals: function() { $document = $(document); $root = $('#product-builder'); }, handleOptions: function() { $document.on('click', '.cpb-option-type-text', function() { var $this = $(this); setTimeout(function(){ if(!$(this).hasClass('cpb-active')) { var $options = $this.closest('.cpb-category').nextAll('.cpb-category').find('.cpb-option-type-text:first:not(.cpb-active)'); if($options.length) { $options.each(function(idx, el) { setTimeout(function() { $(el).click(); },1) }) } } },10) }) } }
Comments
0 comments
Please sign in to leave a comment.