The accept option can take a selector or a function. Both should work for
your case. If you want to accept both items in favorites and items in
categories:

$('#Workspace').droppable({
  accept: '#favorites > *, #categories > *'
});

or

$('#Workspace').droppable({
  accept: '#favorites *, #categories *'
});

or even

$('#Workspace').droppable({
  accept: '#favorites .ui-draggable, #categories .ui-draggable'
});

If you decide to provide a function for accept, each draggable element is
passed to your function for you to process, returning true if your draggable
accepts it, and false if it doesn't:

$('#Workspace').droppable({
  accept: function(draggable) {
    return $(draggable).parents('#favorites').length ||
$(draggable).parents('#categories').length;
  });
});

As far as doing something different in the drop depending on whether the
draggable came from one DIV or the other:

$('#Workspace').droppable({
  ...
  drop: function(event, ui) {
    if ($(ui.draggable).parents('#favorites').length) {
      // alert a message
    }
    if ($(ui.draggable).parents('#categories').length) {
      // insert an item in a db
    }
  }
});

(disclaimer: all untested, but should get you going)

- Richard

On Tue, Jul 21, 2009 at 1:23 PM, jmares79 <jmare...@gmail.com> wrote:

>
> Hi!!! I have a problem:
> I have 1 DIV called "Workspace", and 2 more DIVs, 1 "favorites" and 1
> "categories".
> Well, what I want is that when I drop 1 item from the 1st DIV, have a
> behavior, for example, alert a message, and if I'm dropping an item
> from the 2nd DIV, insert an item in a DB.
> Well, I can't do it, because when I set the "accept" option for the
> second time, it overwrite the first "accept" (which I set for the
> first DIV)
> Reading the docs, I saw that there is a chance ti put a function in
> the "accept" option, but i dont know how to use, since there is no
> concrete examples.
> Ok, that's all, thanks to all.
> Joe
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to jquery-ui@googlegroups.com
To unsubscribe from this group, send email to 
jquery-ui+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to