.droppable doesn't seem to trigger anything? JQuery + ASP
With the help of stackoverflow community, I have a drag and drop to work fine using JQuery. Now I've assigned the .drop class (and made it .droppable), but whenever I drop .draggable onto .droppable ... nothing happens! Is there a bug in javascript?
<script type="text/javascript">
$(document).ready(function() {
doReady();
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function(s, e) {
doReady();
});
});
function doReady() {
$('.drag').draggable({ revert: true,helper: 'clone' });}
$('.drop').droppable({
tolerance: touch,
drop: function() { alert('dropped'); }
});
</script>
The top of the script allows drag and drop and continue after a partial postback.
+1
a source to share
2 answers
There should be a line here
tolerance: "touch",
I will format your code
$(document).ready(function() {
doReady();
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function(s, e) {
doReady();
});
}); // End of document ready
function doReady() {
$('.drag').draggable({ revert: true,helper: 'clone' });
} // End of do ready
$('.drop').droppable({
tolerance: "touch", // Here should be a string
drop: function() { alert('dropped'); }
});
You can see that $ ('. Drop') is not in the doReady function.
Fixed.
function doReady() {
$('.drag').draggable({ revert: true,helper: 'clone' });
$('.drop').droppable({
tolerance: "touch", // Here should be a string
drop: function() { alert('dropped'); }
});
} // End of do ready
+3
a source to share