-
-
Save mschultheiss83/a022c5ffad078eb385e7318746c5004e to your computer and use it in GitHub Desktop.
configurable swatches magento 1.9.1, make first option selected by default -- BETA -- not for production, you will need to make slight mods.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fireEvent(element,event) | |
{ | |
if (document.createEventObject) | |
{ | |
// dispatch for IE | |
var evt = document.createEventObject(); | |
return element.fireEvent('on'+event,evt); | |
} | |
else | |
{ | |
// dispatch for firefox + others | |
var evt = document.createEvent("HTMLEvents"); | |
evt.initEvent(event, true, true ); | |
return !element.dispatchEvent(evt); | |
} | |
} | |
function setDefaultConfigOptions() | |
{ | |
if (spConfigIndex >= spConfig.settings.length) | |
{ | |
return; // stop | |
} | |
spConfig.settings[spConfigIndex].selectedIndex = 1; | |
var obj = spConfig.settings[spConfigIndex]; | |
++spConfigIndex; | |
Event.observe(obj,'change',function(){}); | |
fireEvent(obj,'change'); | |
window.setTimeout("setDefaultConfigOptions()", 1); // Add a small delay before moving onto the next option | |
} | |
var spConfigIndex = 0; | |
Event.observe(window, 'load', function() { | |
setDefaultConfigOptions(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment