Hryhorii
Hryhorii

Reputation: 1243

How can I call click event when drag and drop event

I want change event drag and drop, to click event for my objects. I try this code

 $("a").draggable({
    start: function (event, ui) {
        $(this).trigger("click");
    }
});

But not work :(

UPDATE:

I try this code:

document.ondragstart = function () {
return false;
};

document.onmouseup = function (a, b) {
$(this).trigger("click");
};

But trigger click still not work

Upvotes: 1

Views: 306

Answers (2)

Hryhorii
Hryhorii

Reputation: 1243

I found just such a solution

var url = null;
        $("a").mousedown(function () {
            url = $(this).attr("href");
            $(window).mousemove(function () {
                $(window).unbind("mousemove");
            });
        });
        $(window).mouseup(function () {
            $(window).unbind("mousemove");
            if (url != null) {
                location.href = url;
            }
        });

Upvotes: 0

user1693593
user1693593

Reputation:

Try with this modification:

$("a").draggable({
    start: function (event, ui) {
        $(--your-button-element-here-).click();
    }
});

Upvotes: 1

Related Questions