I am trying out jQuery-UI drag-drop feature. I was able to easily convert a div into a droppable but making a text box a Droppable doesn't work.
jQuery('input[type=text]:visible').droppable({
drop: function (e, ui){
console.log('dropping',ui); //--> this never gets called
jQuery(this).val(jQuery(ui.helper).text());
}
});
Is it the case that the default browser behavior prevents text fields and text areas from being droppables?
EDIT: It doesn't work only when the input field is a part of a draggable..
<span>hello world!<input></span>
$("input").droppable({
drop: function(event, ui) {
alert(ui.draggable.text());
}
});
$("span").draggable({helper:function(){
return jQuery("<span>hello</span>");
}});
是的,它可以是: http : //jsfiddle.net/guNTP/
$("#myinput").droppable({
drop: function(event, ui) {
$(this).val( $(this).val() + ui.draggable.text());
}
});
$("span").draggable({revert:true});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.