/    Sign up×
Community /Pin to ProfileBookmark

droppable does not accept 2 different drop classes

Hi,

I’m trying to have a droppable accepting 2 different class objects that will call 2 different functions. However I cannot find a way to make it work, only the first “drop” action is working, the second one never works. Here is how my code looks like:

$(“#obj1″).droppable({drop: function(event,ui){OnItemRemove($(ui.draggable))},accept:”.class1″});
$(“#obj1″).droppable({drop: function(event,ui){OnItemMove($(ui.draggable))},accept:”.class2″});

if I drag an item of class1, the droppable will call the function OnItemRemove. If I try to drag an item of class2, nothing happen.

Any idea what I’m missing here?

Thanks

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@kaonashiSep 06.2009 — Wouldnt it just be more simple to handle everything in the same drop function?

For example something like:

$("#obj1").droppable({drop: function(event,ui) {

if($(ui.draggable).hasClass("class1))

OnItemRemove($(ui.draggable))

else if ($(ui.draggable).hasClass("class2))

OnItemMove($(ui.draggable))

}
×

Success!

Help @ebouchard spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...