Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 42 lines (23 sloc) 1.788 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.

COPYRIGHT

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.

Something went wrong with that request. Please try again.