I am very new to jquery. Presently i am working on a project of shopping cart where there are three types of items(item1,item2,item3) and three bags(bag1,bag2,bag3) and one shopping cart such as bag1 accepts item1,item2,item3 , bag2 accepts item2,item3 and bag3 accepts only item3 on drop which I have developed so far.
Now i want to add additional functionality such as the user should first select(click) any one of the bag(example bag1) and then try dropping items into the bag1 such that other two bags dropping functionality should be disable(other bags should not accept any item even if it is acceptable by that bag) and also reverse if user selects other bag.
please try it.I really need help.
http://jsfiddle.net/Vwu37/15/
html
<div class="bag1" ><p>bag1</p></div>
<div class="bag2" > <p>bag2</p></div>
<div class="bag3" ><p>bag3</p></div>
<div class="item1"><p>item1_1</p></div>
<div class="item1"><p>item2_1</p></div>
<div class="item1"><p>item2_1</p></div>
js
$('.bag1').droppable({
accept: '.item1,.item2,.item3',
onDragEnter:function(e,source){
$(source).draggable('options').cursor='auto';
},
onDragLeave:function(e,source){
$(source).draggable('options').cursor='not-allowed';
},
onDrop:function(e,source){
var name = $(source).find('p:eq(0)').html();
var price = $(source).find('p:eq(1)').html();
addProduct(name, parseFloat(price.split('$')[1]));
}
});
$('.bag2').droppable({
accept: '.item2,.item3',
onDragEnter:function(e,source){
$(source).draggable('options').cursor='auto';
},
onDragLeave:function(e,source){
$(source).draggable('options').cursor='not-allowed';
},
onDrop:function(e,source){
var name = $(source).find('p:eq(0)').html();
var price = $(source).find('p:eq(1)').html();
}
});
$('.bag3').droppable({
accept: '.item3',
onDragEnter:function(e,source){
$(source).draggable('options').cursor='auto';
},
onDragLeave:function(e,source){
$(source).draggable('options').cursor='not-allowed';
},
onDrop:function(e,source){
var name = $(source).find('p:eq(0)').html();
var price = $(source).find('p:eq(1)').html();
}
});