Added onResult function to type ahead

This commit is contained in:
Safia Abdalla 2015-12-20 19:04:27 -06:00
parent 234cf31d3f
commit 781e4ffd4f

View File

@ -117,6 +117,15 @@ define(function(require){
mod.modal('hide');
};
/* Whenever a result is rendered, if there is only one resulting
* element then automatically select that element.
*/
var onResult = function(node, query, result, resultCount) {
if (resultCount == 1) {
$('.typeahead-list > li:nth-child(2)').addClass('active');
}
};
// generate structure needed for typeahead layout and ability to search
var src = {};
@ -164,7 +173,8 @@ define(function(require){
source: src,
callback: {
onSubmit: onSubmit,
onClickAfter: onSubmit
onClickAfter: onSubmit,
onResult: onResult
},
debug: false,
});