Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This is something I have wanted and needed for a long time. Ordering dragging works great when the widget is set to auto-complete, but is kind of annoying to have to "remember" the names of all the nodes and which one you want to add. It would be awesome if we could get a simple drop-down select widget that is draggable! I know there is the jquery draggable widget but I do not like the look and it is a huge pain to install.
Comment | File | Size | Author |
---|---|---|---|
#5 | multidrag3.js_.txt | 3.17 KB | moondev |
#4 | multidrag2.js_.txt | 1.14 KB | moondev |
#3 | multidrag.png | 17.63 KB | moondev |
#3 | multidrag.js_.txt | 1.14 KB | moondev |
Comments
Comment #1
danielb CreditAttribution: danielb commentedI was going to suggest this myself eventually. I've built this into a few modules like Block reference because some people don't want the autocomplete but still want to reorder the values.
Comment #2
moondev CreditAttribution: moondev commentedI think it may work if I dynamically replace the textfield with a drop-down with jquery, and make sure the values sync up. But I just need a way to get a list of all the available nodes. Then the top select option could have a "none" option with a value of "" (same as highlighting an autocomplete node and deleting the contents.
I know this is hackish but I am desperate for this feature!
Comment #3
moondev CreditAttribution: moondev commentedWell, I got it to work with some jquery! A cool side effect of this is we can hide the [nid] since that info is stored in the select value attribute anyway.
The only issue I am having is I cant seem to target the click event for the "add more items" submit button. I need to call my magic function when that gets clicked otherwise the fields revert back to autocomplete textfields. Any ideas?
Also note that the attached js is more of a proof of concept and is nowhere near polished enough to be solid
Comment #4
moondev CreditAttribution: moondev commentedFound out that the "add more items" event is chained to the mouseDown event. But there was still the problem of waiting for the ahah response to comeback. So I just attached the function to using jQuery's awesome $(document).ajaxStop. Works like a charm!
Just include this file into the footer of your admin theme.
It currently will automatically apply the swap to any autocomplete nodereference field, but I am working on putting this into a module so you can select which items to apply it to, or maybe make it it's own widget.
Comment #5
moondev CreditAttribution: moondev commentedOne more update:
Fixed a loop with the ajaxstop function and allowed the ability for multiple multi-drags to be on one page
Comment #6
moondev CreditAttribution: moondev commentedFYI: I have made a drupal 6.x module for this
http://drupal.org/node/1017756
Comment #7
rogueturnip CreditAttribution: rogueturnip commentedI'd love to use this. Could you post steps on what to do with the JS file?
I'm trying to use node_reference as a field in the module I'm building so ideally I'd like to tag it into that if possible.
Comment #8
jason.fisher CreditAttribution: jason.fisher commentedChanging that order will affect the deltas stored the database? Could this work for ordering a list of checkboxes?
Comment #9
moondev CreditAttribution: moondev commentedI know this is late but figured i would post if it helps anyone. An easy way to accomplish this is to use the fieldgroup module http://drupal.org/project/field_group
Simply create a new fieldgroup, and add a single select-widget node reference. Then make the fieldgroup set to unlimited. Voila! Draggable select boxes :) Hope this helps someone.
Comment #10
drawk CreditAttribution: drawk commentedI did not see a way to make #9 work, at least in D7. "Then make the fieldgroup set to unlimited" - there doesn't seem to be any such option.
Comment #11
jason.fisher CreditAttribution: jason.fisher commentedMaybe #9 meant the field_collection module?
Comment #12
danielb CreditAttribution: danielb commentedI can confirm this is possible with Field collection
http://drupal.org/project/field_collection
Comment #13
Alex Andrascu CreditAttribution: Alex Andrascu commented