Sortable.create does not work with nested ul's unless you declare it a
tree. The problem is that I only want each child li to be sortable
within it's parent ul. Each time I created the sortable for the child,
the Sortable for the parent was destroyed because it was already in the
list and returned as the _findRootElement value.

I'm thinking that Sortable.options should only find the root element if
Sortable.create is dealing with a tree. If it's not, it should only
check for the actual element we are dealing with. Does what I said make
sense?

I got around the issue by overwriting how Sortable.options works before
I create my sortable and then overwriting it again with the original
code immediately after creating the sortable like so (an excerpt from
the class I created):

makeSortable: function() {
                /**
                 * Make sortable options method work the way i want;
                 * I rewrite it to work like the original at the bottom of this 
file.
                 */
                Object.extend(Sortable, {
                        options: function(element) {
                                element = $(element);
                                if(!element) return;
                                return Sortable.sortables[element.id];
                        }
                });

                /**
                 * Create my sortable
                 */
                Sortable.create(this.element.id, {
                        handle: this.options.handle,
                        onUpdate: function() {
                                new Ajax.Request(this.options.reorderUrl, {
                                                method: 'post',
                                                postBody: 
Sortable.serialize(this.element.id, { name:
this.options.postVarName })
                                });
                        }.bind(this)
                });

                /**
                 * Make scriptaculous options work like the originally did
                 */
                Object.extend(Sortable, {
                        options: function(element) {
                                element = Sortable._findRootElement($(element));
                                if(!element) return;
                                return Sortable.sortables[element.id];
                        }
                });
        },


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to