Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;(function($) {
- var dropdown = {
- bindHandlers: function() {
- $(document).on('click', function() {
- $('.dropdown-wrapper').removeClass('active');
- });
- },
- init: function(el) {
- var self = this;
- var parent = $(el);
- var placeholder = $(el).children('span');
- $(el).on('click', function(e) {
- $(this).toggleClass('active');
- return false;
- });
- var options = self.options(el);
- $(options).on('click', function(e) {
- parent.addClass('chosen');
- $(this).parent().find('.active').removeClass('active');
- $(this).addClass('active');
- placeholder.html($(this).find('a').html());
- });
- },
- options: function(el) {
- return $(el).find('ul.dropdown > li');
- },
- };
- $(document).on('ready', function() {
- dropdown.bindHandlers();
- $('.dropdown-wrapper').each(function(i, el) {
- dropdown.init(el);
- });
- });
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement