From ae3ec1d93ecc3b3028470618da72835cb6ccee35 Mon Sep 17 00:00:00 2001 From: rjy7 Date: Tue, 17 Aug 2010 19:31:25 +0000 Subject: [PATCH] NIHVIVO-749 Fixed incorrect behavior in authors form when user hits cancel button with autocomplete selections in view. NIHVIVO-1056 Fixed first scenario, where first/middle name fields appear when autocomplete selection is made using tab. --- .../edit/forms/js/addAuthorsToInformationResource.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/productMods/edit/forms/js/addAuthorsToInformationResource.js b/productMods/edit/forms/js/addAuthorsToInformationResource.js index 4f7b00a8..206ff3ce 100644 --- a/productMods/edit/forms/js/addAuthorsToInformationResource.js +++ b/productMods/edit/forms/js/addAuthorsToInformationResource.js @@ -144,7 +144,7 @@ var addAuthorForm = { this.hideSelectedAuthor(); - this.cancel.unbind('click'); + this.cancel.unbind('click'); this.cancel.bind('click', function() { addAuthorForm.showAuthorListOnlyView(); return false; @@ -498,9 +498,11 @@ var addAuthorForm = { }); this.lastNameField.blur(function() { - // If personUri field has a value, the autocomplete select event has already fired; - // don't do anything. - if (addAuthorForm.personUriField.val()) { + // Cases where this event should be ignored: + // 1. personUri field has a value: the autocomplete select event has already fired. + // 2. The last name field is empty (especially since the field has focus when the form is displayed). + // 3. Autocomplete suggestions are showing. + if ( addAuthorForm.personUriField.val() || !$(this).val() || $('ul.ui-autocomplete li.ui-menu-item').length ) { return; } addAuthorForm.onLastNameChange();