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 9016955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:08:19+00:00 2026-06-16T04:08:19+00:00

I want to delegate an event from one element to another. I have this

  • 0

I want to delegate an event from one element to another. I have this simple test code, and I get an exception:

Error: UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0 ` at line 12 (the dispatch)

I have read this, but the commented line before it, makes no difference. How can I make this work?

Code:

<!DOCTYPE html>
<html>
  <head>
    <script src="jquery.js"></script>
    <script>
    function init(){}

    function delegator(e){
        alert('the first');
        var other = document.getElementById('myCanvas2');
        //e.trigger = other;
        other.dispatchEvent(e);
    }

    $("#myCanvas").live('dblclick', delegator);
    $("#myCanvas2").live('dblclick', function(){alert('the second');});
    </script>
  </head>
  <body>
    <canvas id="myCanvas" style="width:1200px; height:600px; border: solid black 1px;"></canvas>
    <canvas id="myCanvas2" style="width:1200px; height:600px; border: solid black 1px;"></canvas>
  </body>
</html>
  • It is important to me that all the information is going to the delegated object, since it will be replaced with various other objects like a Google Maps canvas or any other service.
  • 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-06-16T04:08:20+00:00Added an answer on June 16, 2026 at 4:08 am
    1. .live was deprecated a while ago.

    2. Since you are using jQuery use .trigger(...)

      function delegator(e){
          alert('the first');
          $('#myCanvas2').trigger(e);
      }
      
      $("#myCanvas").on('dblclick', delegator);
      $("#myCanvas2").on('dblclick', function(){alert('the second');});
      

      Demo: http://jsfiddle.net/maniator/zbJBd/

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

Sidebar

Related Questions

I have read where an event is triggered on another thread from the one
I have bound event as below: $(document).delegate('.budget', 'click', function(e){ if ($(this).hasClass('collapsed')) { $(this).removeClass('collapsed'); $(this).addClass('expanded');
i want to know how Delegate is differ from object in cocoa any good
I want to use jquery delegate to call a function, and this works fine:
I want to pass data from second tab to first tab using delegates.But delegate
I'm making some tabs and I want to have my own delegate for them
Eg. I have following delegate method I want to use as a callback function
I'm trying to delegate a click event to a TR element that contains a
When I delete characters from a UITextField field one-by-one, the delegate method textField:shouldChangeCharactersInRange:replacementString: is
I have a UICollectionViewFlowLayout that basically does what I want, except for one thing

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.