The current behaviour of popups_reference with multi-value nodereference fields, is that it looks for an empty form element to populate with the newly-created reference, and if none is available, it simply overwrites the value of the first already-populated element. This is not ideal.

Attached patch does the following:

  • If no empty nodereference form element is available, it calls jQuery's triggerHandler('mousedown') for the 'Add another item' button (if such a button is available).
  • It wraps the code for populating the newly created reference in a fadeTo() call, in order to delay this for 2 seconds. This is a bit of a hackish solution, but it's the only way I could ensure (albeit still not guarantee) that the AHAH callback for 'add another item' finishes before we try to populate it. Any other ideas are welcome. For now, this works pretty well for me.
  • Makes the newly created reference get added to the nodereference form element with nid, not just with title. We have the nid available, so we should use it.
CommentFileSizeAuthor
popups_reference_trigger_handler.patch2.31 KBJaza
Support from Acquia helps fund testing for Drupal Acquia logo