Mercurial > defr > drupal > popups_reference
changeset 2:92ed2a629336
Only update one autocomplete field after successful node creation
Before the patch, the title of the newly created node would appear in every
inputs of the field, which wasn't all that usefull. The code now only updates
one field, and /tries/ to be smart when making the choice of which one to
update: if there's an empty field, we'll put the value there. If there isn't,
then we'll use the first one.
Ideally, the code would check if the field is configured for "Unlimited"
values, and if it is, try to add a new input instead of blindly overwritting
potentially valuable user input.
author | Franck Deroche <franck@defr.org> |
---|---|
date | Wed, 21 Jan 2009 14:17:45 +0100 |
parents | ece8e4be4d6f |
children | 98642e828c60 |
files | popups_reference.js |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/popups_reference.js Wed Jan 21 11:34:38 2009 +0100 +++ b/popups_reference.js Wed Jan 21 14:17:45 2009 +0100 @@ -41,7 +41,10 @@ var title = popups_reference_get_cookie_value('PopupRefTitle'); title = decodeURIComponent(title); $wrapper.find('select').val(nid); // Select - $wrapper.find('input.form-autocomplete').val(title); // Autocomplete + $wrapper + .find('input.form-autocomplete:not([value]), input.form-autocomplete') + .filter(':first') // Only update the first item in the set + .val(title); // Autocomplete $wrapper.find(':radio[value=' + nid + ']').select(); // Radio buttons }); });