Skip to content

Latest commit

 

History

History
42 lines (23 loc) · 1.75 KB

File metadata and controls

42 lines (23 loc) · 1.75 KB

TUTORIAL

HOW TO CREATE DRAG AND DROP SORTING USING AWESOME NESTED SET AND JQUERY

I have been searching high and low for a plugin that will allow this, and decided to combine a few tools, write a few helper methods and controller actions and roll my own.

You can find awesome_nested_set at:

github.com/collectiveidea/awesome_nested_set with setup instructions (RAILS 2) github.com/galetahub/awesome_nested_set (RAILS 3)

(Thank’s guys, it really lives up to it’s name) - check their wiki for gotchas and cheat sheets

I hope this will help someone else out there having the same problem as I did.

OBJECTIVE

Create an interface to drag and drop categories in a tree-like structure with sorting (using unordered lists)

REQUIREMENTS

This works best with a new set, as I have implemented this in a few existing sets and found that in one particular project, some of the sorting was not working.

Working Example App

Please see the example_app directory for a simple working demo. NOTE: The demo uses rails 2.3.8

UPDATE (28th April 2011)

see rails3 example (rails 3.0.3 ruby 1.8.7) using github.com/galetahub/awesome_nested_set (rails 3 version)

FINAL NOTES

I will admit that this is not the most efficient way of handling this action, but it does work well, especially if you’re not sorting a nested set frequently. I welcome any refactoring suggestions. Feel free to email me at matenia@gmail.com

MENTIONS AND CREDITS

Thank you to Chelsea for helping me iron out some stubborn code during a hack-meetup.

This project is small, but many should find it useful as it took me a week to work this out due to a lack of simple documentation and very little help provided on stackoverflow.