NIHVIVO-725 Initial work on autocomplete filter for existing publications for the author

This commit is contained in:
rjy7 2010-07-11 17:31:41 +00:00
parent 67a3e7a86c
commit d1c8d701c2
3 changed files with 53 additions and 17 deletions

View file

@ -178,7 +178,7 @@ var addAuthorForm = {
url: addAuthorForm.acUrl,
dataType: 'json',
data: request,
complete: function(xhr) {
complete: function(xhr, status) {
// Not sure why, but we need an explicit json parse here. jQuery
// should parse the response text and return a json object.
var results = jQuery.parseJSON(xhr.responseText);

View file

@ -102,9 +102,11 @@ var customForm = {
},
initAutocomplete: function() {
var acFilter = this.getAcFilter();
this.acCache = {};
this.baseAcUrl = $('.acUrl').attr('id');
this.baseAcUrl = customFormData.acUrl;
this.acSelector.autocomplete({
minLength: 3,
@ -120,11 +122,13 @@ var customForm = {
url: customForm.acUrl,
dataType: 'json',
data: request,
complete: function(xhr) {
complete: function(xhr, status) {
// Not sure why, but we need an explicit json parse here. jQuery
// should parse the response text and return a json object.
var results = jQuery.parseJSON(xhr.responseText);
customForm.acCache[request.term] = results;
customForm.acCache[request.term] = results;
response(results);
}
@ -137,6 +141,22 @@ var customForm = {
});
},
getAcFilter: function() {
// RY This gets put on the page for now. May want to put into a js file instead.
var url = $('.sparqlQueryUrl').attr('id');
$.ajax({
url: customFormData.sparqlQueryUrl,
data: {
resultFormat: 'RS_JSON',
query: customFormData.sparqlForAcFilter
},
success: function(data, status, xhr) {
console.log(data);
}
})
},
// Reset some autocomplete values after type is changed
resetAutocomplete: function(typeVal) {