Behavior.Sortable access

37 views
Skip to first unread message

Philip Thompson

unread,
Oct 10, 2012, 10:20:03 PM10/10/12
to mootool...@googlegroups.com
Hi. I am using Behavior.Sortable and it works as desired. I am also using Drag.Move to insert move and insert new list items into my Sortables lists. The new items attach to the list, but I am unable to attach the sortable events on that new list item because I do not have access to the Sortables instance. Is there a way to access the Sortables instance from my drag's onDrop method?

Thanks in advance,
~Philip

Aaron Newton

unread,
Oct 10, 2012, 10:46:07 PM10/10/12
to mootool...@googlegroups.com
elementWithBehaviorSortable.getBehaviorResult('Behavior.Sortable')


You might also consider a Behavior Plugin to bind the two behaviors together.

Philip Thompson

unread,
Oct 11, 2012, 12:25:45 PM10/11/12
to mootool...@googlegroups.com
Excellent! I figured there was a way, but hadn't found it yet. I definitely already thought about making a behavior for those, but wasn't sure how nicely they'd play together. I'll take a stab and see what I can come up with.

Thanks,
~Philip

Aaron Newton

unread,
Oct 11, 2012, 11:10:08 PM10/11/12
to mootool...@googlegroups.com
Behavior filters have no order dependency, which means that the "user" can put them on the element in any order, for example:

<form data-behavior="FormRequest FormValidator">

In this example, the form request instance will be set up and then the validator instance. But it could easily have been the other way around. As such, the filters can't be written to expect any sort of order of operations. This is where Filter Plugins come into play. Plugins DO get an order of operation promise. That is, the filter they modify is ALWAYS applied before they are. So when you need two things to work together, the plugins are the glue.

Philip Thompson

unread,
Oct 18, 2012, 10:35:31 PM10/18/12
to mootool...@googlegroups.com
Next question. Is there a way to specify more than the Behavior.Sortable options? For example, I want to supply Sortables' handle option. I tried

data-sortable-options="{'handle':'.selector'}"

but that didn't give me what I wanted. I know I can create a custom behavior, but didn't want to reinvent the wheel.

Thanks in advance,
~Philip

Aaron Newton

unread,
Oct 18, 2012, 11:21:19 PM10/18/12
to mootool...@googlegroups.com
Yes and no. At issue is that when I implemented the behavior I didn't provide the ability to specify all the available options of sortable:


But it's easy to add. Just add handle: api.getAs(String, 'handle') and you're done. I can add this if you want to open an issue (so you'll get notified when I do it) or you can send me a pull request.
Reply all
Reply to author
Forward
0 new messages