# HG changeset patch # User Franck Deroche # Date 1232543865 -3600 # Node ID 92ed2a6293365bbaa8c08b3889bdfd9066a8afe2 # Parent ece8e4be4d6f81c2891b53fda1c5985f542cacb9 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. diff -r ece8e4be4d6f -r 92ed2a629336 popups_reference.js --- 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 }); });