Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In my program, a div (called 'my_div' here element is draggable:
JavaScript
$("#my_div").draggable();

In this div, there is a table w/ a vertical scrollbar. When I click on the scrollbar of the table, the whole 'my_div' becomes draggable. How can I disable the daggable on the table? I tried this piece of code below but it does not work (see the error message below:
Java
<div id='tbl_RecList' class='styleTable3' >
</div>
...
function preventDraggable(e) {
   e.preventDefault();    // error: Object doesn't support property or method 'preventDefault'
}

What code should be used in the function preventDraggable()? Thanks if you can help.

What I have tried:

Tried preventDefault() but not successful
Posted
Updated 12-Jul-16 4:30am
Comments
Karthik_Mahalingam 6-Jul-16 10:09am    
post the code..
i tried with a small sample it works fine..


<script>
$(function () {
$("#draggable").draggable();
});
</script>
</head>
<body>

<div id="draggable" class="ui-widget-content" style="height:150px; width:150px; overflow:auto">
asfas
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
asfads

</div>


</body>
s yu 6-Jul-16 11:16am    
Tried 2 ways:
1) <div id='tbl_RecList' class='styleTable3' >
2) function preventDraggable(e) {
var v = document.getElementById('creatPDF_div');
v.draggable = false;
}
But when I click the scrollbar, the whole div is still draggable with my mouse move. Could you provide additional advisory? Thanks.
Karthik_Mahalingam 6-Jul-16 11:19am    
tell me how to reproduce the error.so that i can give a solution.
Beginner Luck 7-Jul-16 6:00am    
you want dynamic or static way of getting to become draggable false??

1 solution

Hi,

I am not sure, whether my piece of code will work for you or not, but can you please try once with the below code :

$("#my_div").not("#table_id").draggable();


Please let me know if this won't work for you. I can think of some other solution.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900