Dynamic re-wiring
var typeahead = $('#search').data('typeahead'); if(typeahead) { var orig_show = typeahead.show; typeahead.show = function() { var result = orig_show.apply(typeahead, arguments); var pos = typeahead.$element.offset(); var width = typeahead.$element.outerWidth(); var right = $(window).width() - (pos.left + width); this.$menu.css({ right: right, left: 'auto' }); return result; }; }