I have 5 pieces of a image in a container which i have to drop in another container to complete the image. After the image is dropped in another container i want to add a different class to that image depending upon its ID. so that this image piece will stick to the previous image present in this container.
I am able to implement the drag and drop event and add a single class to each image after drop event. what changes i need to make in my code to add a different class to eachimage depending upon its ID
My code
<style>
.add-style {
position:absolute;
}
.north-style {
width: 375px;top: 10px;left: 11px;
}
.south-style {
width: 375px;top: 158px;left: 11px;
}
.east-style {
width: 163px;top: 10px;left: 223px;height: 250px;
}
.west-style {
width: 163px;top: 9px;left: 11px;height: 249px;
}
.center-style {
width: 126px;top: 71px;left: 135px;
}
</style>
<script>
$(function() {
$( "#sortable1" ).sortable({
connectWith: "div"
});
$( "#sortable2" ).sortable({
connectWith: "div",
stop: function( event, ui ) {
ui.item.addClass( "add-style" )
}
});
$( "#sortable1, #sortable2" ).disableSelection();
});
</script>
Bodypart of code
<body>
<div class="row-fluid" >
<div class="span4">
<div class="span1"></div>
<div id="sortable1" class="well sidebar-nav sidebar-nav-fixed span11">
<legend>Collect Coupon parts</legend>
<span>1st part</span>
<img id="north-img" class="ui-state-highlight" src="images/demo/north.png" >
<span>2nd part</span>
<img id="south-img" class="ui-state-highlight" src="images/demo/south.png" >
<span>3rd part</span>
<img id="east-img" class="ui-state-highlight" src="images/demo/east.png" >
<span">4th part</span>
<img id="west-img" class="ui-state-highlight" src="images/demo/west.png" >
<span>5th part</span>
<img id="center-img" class="ui-state-highlight" src="images/demo/center.png">
</div>
</div>
<div id="sortable2" class=" well sidebar-nav sidebar-nav-fixed span8">
<legend>Canvas section</legend>
</div>
</div>
</body>