Mercurial > defr > drupal > popups_reference
comparison popups_reference.js @ 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 | 990f71344a66 |
comparison
equal
deleted
inserted
replaced
1:ece8e4be4d6f | 2:92ed2a629336 |
---|---|
39 // Info about the new node was placed in a cookie when it was created. | 39 // Info about the new node was placed in a cookie when it was created. |
40 var nid = popups_reference_get_cookie_value('PopupRefNid'); | 40 var nid = popups_reference_get_cookie_value('PopupRefNid'); |
41 var title = popups_reference_get_cookie_value('PopupRefTitle'); | 41 var title = popups_reference_get_cookie_value('PopupRefTitle'); |
42 title = decodeURIComponent(title); | 42 title = decodeURIComponent(title); |
43 $wrapper.find('select').val(nid); // Select | 43 $wrapper.find('select').val(nid); // Select |
44 $wrapper.find('input.form-autocomplete').val(title); // Autocomplete | 44 $wrapper |
45 .find('input.form-autocomplete:not([value]), input.form-autocomplete') | |
46 .filter(':first') // Only update the first item in the set | |
47 .val(title); // Autocomplete | |
45 $wrapper.find(':radio[value=' + nid + ']').select(); // Radio buttons | 48 $wrapper.find(':radio[value=' + nid + ']').select(); // Radio buttons |
46 }); | 49 }); |
47 }); | 50 }); |
48 }); | 51 }); |
49 }; | 52 }; |