Skip to content

Commit

Permalink
Merge pull request olton#206 from icardo/master
Browse files Browse the repository at this point in the history
Update to dropdown.js - Initializing dropdowns loaded via Ajax. (Re-initializing exisitng dropdowns)
  • Loading branch information
olton committed May 2, 2013
2 parents 613dcbe + 24cee0a commit 37fd723
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions javascript/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
$(this).slideUp('fast', function(){});
$(this).parent().removeClass("active");
});
}
};

var initSelectors = function(selectors){
selectors.on('click', function(e){
selectors.off("click.dropdown");
selectors.on('click.dropdown', function(e){
//e.stopPropagation();
//$("[data-role=dropdown]").removeClass("active");
if($(e.originalEvent.target).parent().is("[data-role]")) e.stopPropagation();
Expand All @@ -35,25 +36,25 @@
//$(this).children(".dropdown-menu").hide();
});
$('html').on("click", function(e){
if($(e.originalEvent.target).parents('[data-role="dropdown"]').length == 0)
if(e.originalEvent && $(e.originalEvent.target).parents('[data-role="dropdown"]').length == 0)
clearDropdown();
});
}
};

return this.each(function(){
if ( options ) {
$.extend(defaults, options)
$.extend(defaults, options);
}

initSelectors($this);
});
}
};

$(function () {
$('[data-role="dropdown"]').each(function () {
$(this).Dropdown();
})
})
});
});
})(window.jQuery);


Expand All @@ -78,20 +79,20 @@
}
//$(this).toggleClass("active");
});
}
};

return this.each(function(){
if ( options ) {
$.extend(defaults, options)
$.extend(defaults, options);
}

initSelectors($this);
});
}
};

$(function () {
$('.pull-menu, .menu-pull').each(function () {
$(this).PullDown();
})
})
});
});
})(window.jQuery);

0 comments on commit 37fd723

Please sign in to comment.