jQuery moving element highlights table cells in Firefox
-
20-12-2019 - |
Question
I have the following code:
// Drag Event
var _isMoving = false;
$("body").on("mousedown", ".k-event", function () {
_isMoving = true;
});
// This is here because otherwise the mouse will try and select the grid and looks really ugly
$("body").mousemove(function (e) {
if (_isMoving)
e.preventDefault();
});
$("body").mouseup(function () {
_isMoving = false;
});
On Chrome, this works great.
However, on Firefox, when I try and move the mouse with the mouse button depressed, it still wants to highlight the table cells (as if I were trying to copy/paste something). How can I tell Firefox not to try and highlight anything?
Solution
For Firefox you should prevent the event on the mousedown
event as well:
$("body").on("mousedown", ".k-event", function (e) {
e.preventDefault();
_isMoving = true;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow