Cancel event bubbling from jquery draggable to click on child element on drag stopPreventing click event with jQuery drag and drophow to avoid jQuery UI draggable from also triggering click eventBlur event stops click event from working?Draggable cancel triggering blur eventjQuery clickable element nested in draggable oneJquery drag and drop - click event registers on dropJquery drag and drop - set clickable region in draggable on dropjquery ui drag event to cancel click eventStop event propagation from jquery Draggable stop to onclickHow to stop click event on drag with using angular2-draggable library?
What is the practical impact of using System.Random which is not cryptographically random?
How to load files as a quickfix window at start-up
How were US credit cards verified in-store in the 1980's?
Squares inside a square
Doesn't the concept of marginal utility speak to a cardinal utility function?
Can a system of three stars exist?
Why is Mitch McConnell blocking nominees to the Federal Election Commission?
Displaying Time in HH:MM Format
Could a simple hospital oxygen mask protect from aerosol poison?
Should we run PBKDF2 for every plaintext to be protected or should we run PBKDF2 only once?
Single vs Multiple Try Catch
Function of the separated, individual solar cells on Telstar 1 and 2? Why were they "special"?
Underbrace in equation
Can authors email you PDFs of their textbook for free?
Can a human variant take proficiency in initiative?
Is it good practice to speed up and slow down where not written in a song?
Ways you can end up paying interest on a credit card if you pay the full amount back in due time
How does the search space affect the speed of an ILP solver?
Was there an original & definitive use of alternate dimensions/realities in fiction?
Fishing from underwater domes
Ideas behind the 8.Bd3 line in the 4.Ng5 Two Knights Defense
How to correctly set logical high level on PS/2 port?
'spazieren' - walking in a silly and affected manner?
Why don't "echo -e" commands seem to produce the right output?
Cancel event bubbling from jquery draggable to click on child element on drag stop
Preventing click event with jQuery drag and drophow to avoid jQuery UI draggable from also triggering click eventBlur event stops click event from working?Draggable cancel triggering blur eventjQuery clickable element nested in draggable oneJquery drag and drop - click event registers on dropJquery drag and drop - set clickable region in draggable on dropjquery ui drag event to cancel click eventStop event propagation from jquery Draggable stop to onclickHow to stop click event on drag with using angular2-draggable library?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a draggable div with a clickable tag within it:
<div id='myDiv'>
<a id='mylabel' onclick="alert('i am clicked')">some text</a>
</div>
$("#myDiv").draggable(
stop: function(e)
//want to cancel the click event on the nested a element
//e.preventDefault(); ??
//e.cancelBubble(); ??
);
When I stop dragging, the click event fires, which I don't want. I tried preventDefault and cancel on the stop drop event but the click event still fires. Any ideas anyone?
javascript jquery
add a comment |
I have a draggable div with a clickable tag within it:
<div id='myDiv'>
<a id='mylabel' onclick="alert('i am clicked')">some text</a>
</div>
$("#myDiv").draggable(
stop: function(e)
//want to cancel the click event on the nested a element
//e.preventDefault(); ??
//e.cancelBubble(); ??
);
When I stop dragging, the click event fires, which I don't want. I tried preventDefault and cancel on the stop drop event but the click event still fires. Any ideas anyone?
javascript jquery
Sorry I didnt see the structure before. Typically events go bottom up, so if you are trying to drag thea
element, the click will be fired. The only way to make it work is to put a event.preventDefault on the click which is as good as not putting a click listener on that element.
– varun agarwal
Mar 28 at 2:16
add a comment |
I have a draggable div with a clickable tag within it:
<div id='myDiv'>
<a id='mylabel' onclick="alert('i am clicked')">some text</a>
</div>
$("#myDiv").draggable(
stop: function(e)
//want to cancel the click event on the nested a element
//e.preventDefault(); ??
//e.cancelBubble(); ??
);
When I stop dragging, the click event fires, which I don't want. I tried preventDefault and cancel on the stop drop event but the click event still fires. Any ideas anyone?
javascript jquery
I have a draggable div with a clickable tag within it:
<div id='myDiv'>
<a id='mylabel' onclick="alert('i am clicked')">some text</a>
</div>
$("#myDiv").draggable(
stop: function(e)
//want to cancel the click event on the nested a element
//e.preventDefault(); ??
//e.cancelBubble(); ??
);
When I stop dragging, the click event fires, which I don't want. I tried preventDefault and cancel on the stop drop event but the click event still fires. Any ideas anyone?
javascript jquery
javascript jquery
asked Mar 28 at 0:35
ProgramnikProgramnik
8436 silver badges11 bronze badges
8436 silver badges11 bronze badges
Sorry I didnt see the structure before. Typically events go bottom up, so if you are trying to drag thea
element, the click will be fired. The only way to make it work is to put a event.preventDefault on the click which is as good as not putting a click listener on that element.
– varun agarwal
Mar 28 at 2:16
add a comment |
Sorry I didnt see the structure before. Typically events go bottom up, so if you are trying to drag thea
element, the click will be fired. The only way to make it work is to put a event.preventDefault on the click which is as good as not putting a click listener on that element.
– varun agarwal
Mar 28 at 2:16
Sorry I didnt see the structure before. Typically events go bottom up, so if you are trying to drag the
a
element, the click will be fired. The only way to make it work is to put a event.preventDefault on the click which is as good as not putting a click listener on that element.– varun agarwal
Mar 28 at 2:16
Sorry I didnt see the structure before. Typically events go bottom up, so if you are trying to drag the
a
element, the click will be fired. The only way to make it work is to put a event.preventDefault on the click which is as good as not putting a click listener on that element.– varun agarwal
Mar 28 at 2:16
add a comment |
1 Answer
1
active
oldest
votes
I figured it out. The trick is to attach a click event to the draggable div like so:
$("#myDiv").click(event.stopPropagation());
Because dragging the div also invokes a click event, which then propagates to the child a tag, the stop drag event is the wrong thing to stop. Removing click propagation is the way to go.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55388514%2fcancel-event-bubbling-from-jquery-draggable-to-click-on-child-element-on-drag-st%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I figured it out. The trick is to attach a click event to the draggable div like so:
$("#myDiv").click(event.stopPropagation());
Because dragging the div also invokes a click event, which then propagates to the child a tag, the stop drag event is the wrong thing to stop. Removing click propagation is the way to go.
add a comment |
I figured it out. The trick is to attach a click event to the draggable div like so:
$("#myDiv").click(event.stopPropagation());
Because dragging the div also invokes a click event, which then propagates to the child a tag, the stop drag event is the wrong thing to stop. Removing click propagation is the way to go.
add a comment |
I figured it out. The trick is to attach a click event to the draggable div like so:
$("#myDiv").click(event.stopPropagation());
Because dragging the div also invokes a click event, which then propagates to the child a tag, the stop drag event is the wrong thing to stop. Removing click propagation is the way to go.
I figured it out. The trick is to attach a click event to the draggable div like so:
$("#myDiv").click(event.stopPropagation());
Because dragging the div also invokes a click event, which then propagates to the child a tag, the stop drag event is the wrong thing to stop. Removing click propagation is the way to go.
answered Mar 28 at 2:15
ProgramnikProgramnik
8436 silver badges11 bronze badges
8436 silver badges11 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55388514%2fcancel-event-bubbling-from-jquery-draggable-to-click-on-child-element-on-drag-st%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Sorry I didnt see the structure before. Typically events go bottom up, so if you are trying to drag the
a
element, the click will be fired. The only way to make it work is to put a event.preventDefault on the click which is as good as not putting a click listener on that element.– varun agarwal
Mar 28 at 2:16