0

I'm trying to extend the dropdown in Bootstrap 3 to drop downwards or upwards depending on whether if the content would be visible or not. As an example, if the dropdown would expand below what's visible on the screen it should drop up instead.

I have been trying to add this behaviour by extending the prototype by changing the toogle function of the dropdowns prototype

var toggleDropdown = $.fn.dropdown.Constructor.prototype.toggle;
$.fn.dropdown.Constructor.prototype.toggle = function (e) {
    toggleDropdown.apply(this, arguments)
    alert('toggle fired')
}

I took inspiration from this SO thread: How to Extend Twitter Bootstrap Plugin. However this doesn't seem to be working. When I print the toggle function in the console it seems to be replaced but when I click on a dropdown, the old code is still executed and not my new one. Does anyone know why the old prototype function is being executed even though I have replaced it with a new one? It would also be much appriciated if anyone could guide me in how to extend bootstrap in the best way.

Community
  • 1
  • 1
Abris
  • 1,451
  • 3
  • 18
  • 38

0 Answers0