Created
January 14, 2016 15:49
-
-
Save ABM-Dan/70316682296df8e044fb to your computer and use it in GitHub Desktop.
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
var selectricOptions = { | |
disableOnMobile: false, | |
onInit: function () { | |
var label, selectedClass, selectricWrapper; | |
selectricWrapper = $(this).parents('.selectric-wrapper'); | |
selectedClass = selectricWrapper.find('option:selected').attr('class'); | |
label = selectricWrapper.find('.label'); | |
label.addClass(selectedClass); | |
if ($(this).data('placeholder')) { | |
return label.text($(this).data('placeholder')); | |
} | |
}, | |
onBeforeOpen: function () { | |
var options; | |
options = $(this).find('option'); | |
return $(this).parent().siblings('.selectric-items').find('li').each(function (index, el) { | |
var currentClass; | |
currentClass = options.eq(index).attr('class'); | |
return $(el).addClass(currentClass).data('class', currentClass); | |
}); | |
}, | |
onChange: function() { | |
var pickedClass; | |
pickedClass = $(this).parent().siblings('.selectric-items').find('li.selected').data('class'); | |
return $(this).parents('.selectric-wrapper').find('.label').attr('class', 'label ' + pickedClass + ' changed'); | |
} | |
}; | |
selectricOptions.onRefresh = selectricOptions.onChange; | |
$('select.selectric').selectric(selectricOptions); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment