Index: popups_reference.js =================================================================== --- popups_reference.js (revision 4) +++ popups_reference.js (working copy) @@ -6,6 +6,8 @@ * Adds the behavior of selecting the newly created node. */ +var rel = {}; + /** * Parse the cookies to find a value. * @@ -29,11 +31,11 @@ $('.popups-reference', context).not('.popups-reference-processed').each(function() { $(this).addClass('popups-reference-processed'); // Don't re-add to processed links. $(this).click(function() { - var rel = $(this).attr('rel'); // Rel attribute of the clicked link is the wrapper id. + rel = $(this).attr('rel'); // Rel attribute of the clicked link is the wrapper id. var $wrapper = $('#' + rel); // Unbind namespaced event, so bindings don't pile up every click. $(document).unbind('popups_form_success.popups_reference'); - + // Bind to the popups API custom form_success event. $(document).bind('popups_form_success.popups_reference', function() { // Info about the new node was placed in a cookie when it was created. @@ -41,7 +43,7 @@ var title = decodeURIComponent(popups_reference_get_cookie_value('PopupRefTitle')); $wrapper.find('select').val(nid); // Select $wrapper.find(':radio[value=' + nid + ']').select(); // Radio buttons - + // Get the first empty autocomplete field to fill (http://drupal.org/node/388406). $emptyAutos = $wrapper.find('input.form-autocomplete').filter(function(i) { return !$(this).val(); @@ -50,7 +52,8 @@ $emptyAutos.eq(0).val(title); } else { // There are no empty fields, use the first one. - $wrapper.find('input.form-autocomplete:first').val(title); + var content = title + ' [nid:'+ nid +']'; + $('.'+ rel).find('input.form-autocomplete:first').val(content); } }); });