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

  • Home
  • SEARCH
  • 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 8761041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:11:44+00:00 2026-06-13T15:11:44+00:00

What I need is something like: var MyEventPointer = $(‘body’).on(‘MyCustomEvent’,’.myClass’,function(e){ // do something });

  • 0

What I need is something like:

var MyEventPointer = $('body').on('MyCustomEvent','.myClass',function(e){
   // do something
});

var MyEventPointer2 = $('body').on('MyCustomEvent','.myClass',function(e){
   // do something
});

$('body').unbindByEventID(MyEventPointer);

MyEventPointer is a pointer to a specific event handler. Even though the two event handlers are exactly identical, only one is unbound because they have different unique identifiers, returned on creation. This should work like the way I can store a reference to a timer in a variable and disable the timer again later using its reference. I know Jquery stores Unique IDs for events, but I don’t know if I can get to them. Is this possible to do with Jquery or will I need to role my own solution? The event needs to be delegated so that both current and future instances of .myClass are included.

Update:

Sample Code:

<tr><td><input class="MyWidget" /></td></tr>
<tr><td><input class="MyWidget" /></td></tr>
<tr><td><input class="MyWidget" /></td></tr>
<!-- Repeats n times, rows are added and deleted dynamically -->    

JavaScript:

// Creation
$('.MyWidget').MyWidget();


// The plugin
$.fn.MyWidget = function (options) {
   return this.each(function () {
      new ATK.MyWidget(this, options);
   });
};

// The widget class
ATK.MyWidget = function (element, options) {
   // constructor
}
ATK.MyWidget.prototype = new ATK.ParentWidget();

ATK.MyWidget.prototype.SetFilterEvent = function(Selector) {
   var base = this;   
   $('body').on('MyCustomEvent',Selector,function(e){base.eMyCustomEvent(e,this)});
}

ATK.MyWidget.prototype.eMyCustomEvent = function(e,eventThis) {
   console.log(this.protected.$element.attr('id')+' has detected that '+$(eventThis).attr('id')+' has changed.');
}
  • 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-13T15:11:45+00:00Added an answer on June 13, 2026 at 3:11 pm

    You can do that like this:

    function MyEventPointer1(e){
       // do something
    });
    
    function MyEventPointer2(e){
       // do something
    });
    
    $('body').on('MyCustomEvent','.myClass', MyEventPointer1);
    $('body').on('MyCustomEvent','.myClass', MyEventPointer2);
    
    $('body').off('MyCustomEvent','.myClass', MyEventPointer1);
    

    More specifically in your case with classes, you can easily apply the above pattern and it works:

    ATK.MyWidget.prototype.SetFilterEvent = function(Selector) {
        this.event = function(e) {this.eMyCustomEvent(e, this);}
        $('body').on('MyCustomEvent',Selector,this.event);
    }
    
    ATK.MyWidget.prototype.RemoveFilterEvent = function(Selector) {
        $('body').off('MyCustomEvent',Selector,this.event);
    }
    

    (You might want to check to make sure that this.event isn’t null and set it to null in the constructor, or maybe it’s more efficient to declare this.event in the constructor to be this function, or something like that, but this basically does the job.)

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

Sidebar

Related Questions

I think I need something like ruby's splat * here. function foo() { var
I have an array that I need to unpack. So, from something like var
If I need to do something like this: var connection = new Connection(host); connection.Execute(Commands.Delete);
I need something like this. var thing_<?php echo $php_var->n ?> = <?php echo '32'
I need to do something like this: var Layers = { TL: null, TM:
I need something like this: var link = http://www.google.com; <a href='link' /> So I
Inside a Matlab function I need something like (as you can imagine in real
I need something like make i.e. dependencies + executing shell commands where failing command
I need something like this http://jonraasch.com/blog/a-simple-jquery-slideshow but w/o the absolute positioning. Is it possible?
I need something like a temporary in-memory key-value store. I know there are solutions

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.