I have an img element which is draggable. Now I want to trigger the drag() event manually like how do we trigger 'click' event as $(element).trigger('click'). Thanks.
Here is the function definition that I have
$('#imgToUpload').draggable({
drag: function(event, ui) {
if (ui.position.top > 0) {
ui.position.top = 0;
}
var maxtop = ui.helper.parent().height() - ui.helper.height();
if ( ui.position.top < maxtop) {
ui.position.top = maxtop;
}
if ( ui.position.left > 0) {
ui.position.left = 0;
}
var maxleft = ui.helper.parent().width() - ui.helper.width();
if ( ui.position.left < maxleft) {
ui.position.left = maxleft;
}
ImageCropping.calculateCroppedCoordinates();
}
});
Here is jquery ui plugin
include that on the page and then simply use
$("#myElement").simulate('drag');