views:

44

answers:

0

I have this code for a drag and drop portion of my site, I use this HTML first off,

<li class="drag_check">                                 
  <input type="checkbox" value="Y"  class="cv_choice" name="cv_file[<?=$rslt['code'];?>]" id="inp_cv_<?=$rslt['code'];?>" />
</li>

and then this code for the drag and drop:

var cv_file = new Array();
$(".drag_check").mouseenter(function() {
    $(this).css('cursor', 'move');
});
$(".drag_check").draggable({helper:"clone", opacity:"0.5", revert: 'invalid'});
$(".searchPage").droppable({
    accept:".drag_check",
    activeClass:"ui-state-hover",
    hoverClass: "dropHover",
    drop: function(ev, ui) {
        var droppedItem = ui.draggable.children();
        cv_file = ui.draggable.map(function() {//map the names and values of each of the selected checkboxes into array
            return ui.draggable.children().attr('name')+"="+ui.draggable.children().attr('value');
        }).get();
        var link = ui.draggable.children().attr('name').substr(ui.draggable.children().attr('name').indexOf("[")+1, ui.draggable.children().attr('name').lastIndexOf("]")-8)
        $.ajax({
            type:"POST", 
            url:"/search",
            data:ui.draggable.children().attr('name')+"="+ui.draggable.children().val()+"&save=Save CVs",
            success:function(){
                $('.shortList').append('<li class="option"><a href="/cv/'+link+'/">'+link+'</a><span class="fakebox"><input style="display:none;" type="checkbox"  class="fakecheck" name="remove_cv'+link+'" value="Y" /></span></li>');
                $('.searchPage').css("border", "solid 3px #E2E5F1").fadeIn(1000);
                //ui.draggable.parent().parent().addClass('class');
                hideElements();
                ui.draggable.parent().addClass('added');


            },
            error:function() {
                alert("Somthing has gone wrong");
            }
        });

    }
});

I am wanting to add a class to the parent li of the input that has been dragged when it has been dragged successfully is this possible and how?