Today I'd like to present you a little snippet to add open/closed classes within MSDropdown jQuery Plugin!
Explicitly this plugin is used within Drupals Language switcher dropdown / lang_dropdown Module.
Therefore we needed open/closed classes to determine the current state of selection for CSS purposes.
Fortunately the plugin developer (thank you so much, really great development!) was so gracious to provide "onOpen" and "onClose" events to hook into.
So the last challenge was to pick the MsDropdown object within DOM to add the events. And it worked!
Here are the results as snippet, feel free to use and modify:
(function ($) {
// Initial values:
$('#edit-lang-dropdown-select_msdd').addClass('closed').removeClass('open');
// Events
var oHandler = $('select#edit-lang-dropdown-select').data("dd");
oHandler.addMyEvent('onOpen', function(){
$('#edit-lang-dropdown-select_msdd').addClass('open').removeClass('closed');
});
oHandler.addMyEvent('onClose', function(){
$('#edit-lang-dropdown-select_msdd').addClass('closed').removeClass('open');
});
})(jQuery);
More about the plugin and download:
http://www.marghoobsuleman.com/jquery-image-dropdown
https://github.com/marghoobsuleman/ms-Dropdown
Dir hat dieser Beitrag Zeit und viele Nerven gespart?
Dann würde ich mich sehr über einen leckeren Kaffee freuen! Oder ein spannendes Tech-Buch aus meiner Wunschliste?

Du suchst weitere professionelle Unterstützung in der Web-Softwareentwicklung?
Unser erfahrenes Team der webks GmbH berät, entwickelt & realisiert individuelle, innovative Web-, eCommerce-, Drupal CMS & mobile Anwendungen.

