Issue 1:

When using the ERB for multiple fields on one node type I had an issue where clicking [remove] threw a JS error and broke the widget.

instanceId = ui.item.attr('id'),

Was returning undefined because my ul element didn't have an ID. I changed line 80 to:

list = item.closest('[id^=entityreference-browser]');
instead of
list = item.closest('ul');

This finds the widget id that matches Drupal.settings.entityreference_browser even when multiple widgets are used on the same page.

Issue 2:
Without passing context to $('body') selector, the events are fired 1 time for each browser on the form

Below fixed the issue:
$('body', context)

Patch is also attached for both if others have the same issues.

CommentFileSizeAuthor
multiple-widgets-js-issues.patch1.08 KBandyg5000

Comments

drupix’s picture

FYI : for me, this patch also fixed (on node edit form) "the [remove] link redirecting to some URL" described in this issue On User view with ERB, the [remove] link wants to redirect to some URL

jdanthinne’s picture

Status: Active » Reviewed & tested by the community

Working for me as well.

davidseth’s picture

Assigned: Unassigned » davidseth

@andyg5000, sorry for the lack of attention to this patch. I have recently (in the last few months) moved from Tasmania to Queensland, got a new job with Acquia, and had a baby boy!! So it has been slightly busy.

I will review your work as soon as possible and commit if all is good. Thanks again for your help.

@drupix & @jdanthinne thank you both for testing this patch!!

Cheers,

David

andyg5000’s picture

Dude, Congrats! All great things happening for you. It's been a while since I've looked at this, but I'm using this module for a pretty major project so feel free to ping me on d.o or IRC if you need help. Thanks!
-A

davidseth’s picture

@andyg5000 thanks mate!

Good to hear that you are using this in a major project. Can you share a bit more info on that?

Cheers,

David

andyg5000’s picture

Hey David,

Well major for me... It's a privately funded project for a client of mine. We're using the module to assign users and other entities to each other. It's worked out really well for us. You've gotten quite a lot of action for a sandbox project :P

-A

davidseth’s picture

Status: Reviewed & tested by the community » Closed (fixed)

Thanks @andyg5000. Patch has been committed: http://drupalcode.org/sandbox/davidseth/1489176.git/commit/4d7c705

Yes, the sandbox needs to be pushed to the public module section. I think it is (has been) used in a number of projects and I know of a lot of others who could benefit if it was more visible.

Cheers,

David