I am trying to make form elements draggable using jQuery UI. For example, buttons, checkboxes, textfields, etc. So far I have had no luck. Do you have any ideas how to accomplish this?
Maybe 3 years too late but you could dispatch event and use following snippet for a more expected behaviour:
DEMO jsFiddle
$(".draggable").draggable({
start: function (event, ui) {
$(this).data('preventBehaviour', true);
}
});
$(".draggable").find(":input").on('mousedown', function (e) {
var mdown = new MouseEvent("mousedown", {
screenX: e.screenX,
screenY: e.screenY,
clientX: e.clientX,
clientY: e.clientY,
view: window
});
$(this).closest('.draggable')[0].dispatchEvent(mdown);
}).on('click', function (e) {
var $draggable = $(this).closest('.draggable');
if ($draggable.data("preventBehaviour")) {
e.preventDefault();
$draggable.data("preventBehaviour", false)
}
});
Another option is to put it in wrapper and set this CSS for the input:
pointer-events: none;
You wan't be able to enter modify the input values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With