Skip to content

Add new item to the end of ordered multiselect instead of beginning#2167

Merged
mshibuya merged 2 commits into
railsadminteam:masterfrom
dwbutler:ordered-multiselect-append-new
Aug 4, 2015
Merged

Add new item to the end of ordered multiselect instead of beginning#2167
mshibuya merged 2 commits into
railsadminteam:masterfrom
dwbutler:ordered-multiselect-append-new

Conversation

@dwbutler

Copy link
Copy Markdown
Contributor

I'm using the filtering multiselect in a nested form with orderable: true. For our use case, it is very important that elements are always in the right order.

I noticed that when you create a new item, visually the new <option> appears to be added as the last child of the <select>. But when the form is submitted to Rails, the new IDs have actually been inserted at the beginning instead of at the end.

I finally tracked this down to a hidden <select> which is the real one submitted via Ajax. Changing prepend to append fixed the issue, causing new <option>s to be inserted at the end of the hidden <select>.

I would be happy to write some specs, but I couldn't find any existing specs for the multiselect widget. Maybe I just need to be pointed to the right file or create a new one.

@luizpicolo

Copy link
Copy Markdown
Contributor

👍

@dwbutler

dwbutler commented Aug 3, 2015

Copy link
Copy Markdown
Contributor Author

@sferik Anything blocking this from getting merged?

mshibuya added a commit that referenced this pull request Aug 4, 2015
Add new item to the end of ordered multiselect instead of beginning
@mshibuya mshibuya merged commit f8647e6 into railsadminteam:master Aug 4, 2015
@mshibuya

mshibuya commented Aug 4, 2015

Copy link
Copy Markdown
Member

Merging in, thanks!

@dwbutler

dwbutler commented Aug 6, 2015

Copy link
Copy Markdown
Contributor Author

@mshibuya Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants