Im using ddSlick plugin for jQuery and the method onSelected should only run when I have chosen an option from the created Dropdown.
Only problem is that the following code I have seems to run the onSelected as soon as the page loads.
Can anyone point me in the right direction?
$('#flag').ddslick({
imagePosition:"left",
background:"none",
width:"66px",
onSelected: function(data){
var chosenCountry = data.selectedData.value;
chosenCountry = chosenCountry.toLowerCase();
if(data.selectedIndex > 0) {
if( new_url[1] in oc(['de', 'es','fr','it']) ) {
console.log("translated pages");
}
} else {
console.log("English site");
}
}
});
jsFiddle
Thanks
I have invented a solution after hours of figuring out whats the problem.
I directly change something on the code.
Note: you need to use the unminified version to follow this instructions.
on line 220
find:
function selectIndex(obj, index) {
change it to:
function selectIndex(obj, index, a) {
Line 270
find:
if (typeof settings.onSelected == 'function') {
settings.onSelected.call(this, pluginData);
}
change it to:
if (typeof settings.onSelected == 'function') {
if (a !== true) settings.onSelected.call(this, pluginData);
}
And finally on line 146
find
selectIndex(obj, index)
then change it to
selectIndex(obj, index, true)
Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With