Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4252840
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:52:10+00:00 2026-05-21T04:52:10+00:00

i have a problem with the right-click-contextmenu i try to delete a div $(.global_class).live(‘mousedown’,

  • 0

i have a problem with the right-click-contextmenu

i try to delete a div

$(".global_class").live('mousedown', function(e)
{
    if( (e.which == 3) ) 
    {
       // $('#'+this.id+'').remove();
       del_function(this.id);
    }
    e.preventDefault();
}).live('contextmenu', function(e){  e.preventDefault(); });

This code works but the problem is the $('#'+this.id+'').remove();

jquery removes the div and the live $(".global_class").live('mousedown', function(e) didn’t start (result -> the context menu will not be blocked).

Hope someone can help me.

Thanks in advance!
Peter

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:52:11+00:00Added an answer on May 21, 2026 at 4:52 am

    When you remove the elements that are involved in an event, results in terms of bubbling and defaults and such get a bit squirrelly (even without jQuery’s live being involved). You could do this:

    $(".global_class").live('mousedown', function(e)
    {
        var id = this.id;
    
        if( (e.which == 3) ) 
        {
           setTimeout(function() {
                del_function(id);
           }, 0);
        }
        e.preventDefault();
    }).live('contextmenu', function(e){  e.preventDefault(); });
    

    …so that you remove the div immediately after the event finishes, rather than during the event.


    Off-topic, but you can’t cancel the contextmenu event on all browsers (Opera comes to mind), which you may want to factor into your UI decisions…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Contextmenu with a ListBox inside. Whenever I right click my control
So I have created a context box upon right click that has Add/Edit/Delete Rows.
I have used oncontextmenu to call a function on mouse right-click, it is working
I have a problem getting the right Price for a product based on Effectivity
I have come across quite a wired problem right now. I am using ASP.NET
I have a problem in choosing the right method to accomplish my goal. I'm
I have a problem with this code right here: - (void)fetchedData:(NSData *)responseData { //parse
I have a problem here. Right now I'm doing my Web Based Application, my
So, i have a problem with my engine that i am working on right
I need a little push in the right direction. Here's my problem: I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.