views:

48

answers:

0

I have a problem.
I drop element into #projectsActive. New element have been created there. Old element have been deleted with fadeOut

But ajax query sometimes isn't running.

What's the reason?

$("#projectsActive").droppable({
    drop: function (event, elem)
    {
        var e = elem.draggable;
        var linkToSend = "/Projects/Publish/" + $(e).attr("projectid");

        $.ajax({ url: linkToSend });
        var projectid = $(e).attr("projectid");
        var innerText = "";
        if ($(e).find("a").length > 0)
        {
            innerText = $(e).children("a").html();
        }
        else
        {
            innerText = $(e).html();
        }
        var newObject = '<li class="project dragg" projectid="' + projectid + '"><a href="/Projects/' + projectid + '">' + innerText + '</a></li>';



        $(e).fadeOut("fast", function ()
        {
            $("#projectsActive").append(newObject);
            $(this).remove();

            BindDrags();

        });

    }
});