diff --git a/static/js/autocompleter.js b/static/js/autocompleter.js index 81b878675..15f3f1a8c 100644 --- a/static/js/autocompleter.js +++ b/static/js/autocompleter.js @@ -70,10 +70,13 @@ }, select_entry: function(evt) { + var $link; if (evt != undefined) { evt.preventDefault(); + $link = $(evt.target); + } else { + $link = this.$menu.find('.active > a'); } - var $link = this.$menu.find('.active > a'); var curvalue = this.$element.attr("value"); this.$element.attr("value", curvalue.substr( diff --git a/static/js/global.js b/static/js/global.js index 72c9b7a95..c6a216864 100644 --- a/static/js/global.js +++ b/static/js/global.js @@ -206,17 +206,18 @@ function simple_ajax_request(e) { * Simple function that redirect ajax requests to the login page if * the status code received with a response is equal to 278. */ -function ajax_login_redirect() { - if (this.status != 278) { +function ajax_login_redirect(xhr) { + if (xhr.status != 278) { return; } var params = "?next=" + window.location.pathname; window.location.href = - this.xhr.getResponseHeader("Location").replace(/\?.*$/, params); + xhr.getResponseHeader("Location").replace(/\?.*$/, params); } $(document).ready(function() { + $(document).ajaxSuccess(function(e, xhr, settings) { ajax_login_redirect(xhr); }); $(document).on('click', 'a[data-toggle="ajaxmodal"]', modalbox); $(document).on('click', 'a[data-toggle="ajaxmodal-autowidth"]', modalbox_autowidth); }); \ No newline at end of file