Update: got it figured out, at least for the most part. I found that
patched code to be overkill for the current version of scriptaculous
(1.8.2) which is maybe why it hasn't been updated since 1.8.1.

I still had to patch the Sortable#mark method (function wrapping to
the rescue) but other than that, was able to leverage existing
sortable callbacks. If the onChange callback just passed over the
dropon and position variables then this would all work out of the box.

My fix is a total hack, but it works. I store the dropon and position
variables as properties on the sortable object so that I can access
them in my custom onChange callback:

//
**************************************************************************
Sortable.mark = Sortable.mark.wrap(function(){
  var args = $A(arguments), proceed = args.shift();
  proceed.apply(this, args);

  var sortable = Sortable.options(args[0]);
  sortable.markedElement = args[0];
  sortable.markedPosition = args[1];
});
//
**************************************************************************

Then in the onChange callback for your sortable you can do something
like:

//
**************************************************************************
function sortableOnChangeCallback(element){
  var sortable = Sortable.options(element); // fetch the sortable
object
  $('content').select('.placeholder-block').invoke('remove'); //
remove any existing placeholders
  var placeholder = new Element('div', {'class':'placeholder-
block'}).update('<h3>I am a placeholder</h3>'); // create the
placeholder

  if (sortable.markedPosition == 'before'){
    // insert the placeholder before the marked element if applicable
    element.parentNode.insertBefore(placeholder,
sortable.markedElement);
  } else {
    // otherwise insert the placeholder after the marked element or at
the end of the list if the marked element is the last element in the
list
    if (sortable.markedElement.nextSibling)
element.parentNode.insertBefore(placeholder,
sortable.markedElement.nextSibling);
    else element.parentNode.appendChild(placeholder);
  }
}
//
**************************************************************************

Then you just need to make sure that you remove the placeholder in
your onUpdate callback (invoked when the list is reordered)

//
**************************************************************************
function sortableOnUpdate(sortableElement){
  sortableElement.select('.placeholder-block').invoke('remove');
}
//
**************************************************************************

Hope this helps somebody who is messing around with sortables. 
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to