-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogramme_search.js
More file actions
39 lines (28 loc) · 958 Bytes
/
programme_search.js
File metadata and controls
39 lines (28 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(function ($) {
Drupal.behaviors.programmeSearch = {
attach: function (context) {
$('#edit-search-programmes').focus(
function(){
$(this).val('');
});
/* If using Drupal core version < 7.36, this requires a patch to
autocomplete.js. See issue: https://www.drupal.org/node/365241. */
$("#edit-search-programmes", context).bind('autocompleteSelect', function(event, node) {
var key = $(node).data('autocompleteValue');
var label = $(node).text();
// If matches found...
if (key != '0') {
// Set the value of this field.
$(this).val(label);
// Redirect user to entity path.
window.location = Drupal.settings.basePath + key;
}
else {
// If no matches, reset.
$(this).val('');
$(this).focus();
}
});
}
};
})(jQuery);