NIHVIVO-647 Initial implementation of autocomplete
This commit is contained in:
parent
c5506d1a06
commit
ce3f56f800
1 changed files with 12 additions and 9 deletions
|
@ -89,17 +89,17 @@ var customForm = {
|
||||||
if ($(this).val().length) {
|
if ($(this).val().length) {
|
||||||
customForm.labelFieldLabel.html(customForm.getSelectedTypeName() + ' ' + customForm.baseLabelText);
|
customForm.labelFieldLabel.html(customForm.getSelectedTypeName() + ' ' + customForm.baseLabelText);
|
||||||
customForm.initFormFullView();
|
customForm.initFormFullView();
|
||||||
|
// Set the type of individual that the autocomplete will search for
|
||||||
// *** set ac type
|
customForm.setAcUrl($(this).val());
|
||||||
|
console.log("ac url = " + customForm.acUrl);
|
||||||
}
|
}
|
||||||
// do we need else case? i.e. if user has set back to "select one", we should undo
|
// do we need else case? i.e. if user has set back to "select one", we should undo
|
||||||
// above settings? YES - undo ac type and label field label
|
// above settings? Will it matter? they can't proceed till they've made a new selection.
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
initAutocomplete: function() {
|
initAutocomplete: function() {
|
||||||
// Make cache a property of this so we can access it after removing
|
|
||||||
// an author.
|
|
||||||
this.acCache = {};
|
this.acCache = {};
|
||||||
this.baseAcUrl = $('.acUrl').attr('id');
|
this.baseAcUrl = $('.acUrl').attr('id');
|
||||||
|
|
||||||
|
@ -113,9 +113,6 @@ var customForm = {
|
||||||
}
|
}
|
||||||
// console.log('not getting term from cache');
|
// console.log('not getting term from cache');
|
||||||
|
|
||||||
// If the url query params are too long, we could do a post
|
|
||||||
// here instead of a get. Add the exclude uris to the data
|
|
||||||
// rather than to the url.
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: customForm.acUrl,
|
url: customForm.acUrl,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
@ -136,7 +133,13 @@ var customForm = {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Append the type parameter to the base autocomplete url
|
||||||
|
setAcUrl: function(typeVal) {
|
||||||
|
var glue = this.baseAcUrl.indexOf('?') > -1 ? '&' : '?';
|
||||||
|
this.acUrl = this.baseAcUrl + glue + 'type=' + typeVal;
|
||||||
|
},
|
||||||
|
|
||||||
showAutocompleteSelection: function(ui) {
|
showAutocompleteSelection: function(ui) {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue