views:

13

answers:

0

I have a typical HABTM relationship between members (actual members of our organization, not all have online accounts) and users (online accounts). I have an edit users page for site administrators where multiple members can be assigned to users.

There are too many members to reasonably use checkboxes or a multi-select dropdown. I have decided to use dropdowns that are added by clicking an "Add Member" button that uses an AJAX function to add a dropdown.

Here's what I have working:

  • I can add dropdowns and pick any member. On save, the relationships are established.

  • I can edit that user and add more members, remove members, and change members in the dropdown.

The final piece I am struggling with is having my remove link (next to each member drop down) remove a drop down for a new user. The reason being that the action behind the remove link relies on the id of the div that contains the dropdown. When editing a user, this id is generated based on the selected member. For a new user, I do not know the selected member in the dropdown, so I can't assign it an id that I can know about when the remove link is clicked.

Are dropdowns the way to go? Are there any good tutorials or examples of what I am describing out there? Should I perhaps update the div ID in an onchange event in the dropdown?