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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:54:11+00:00 2026-06-16T11:54:11+00:00

I’ve been having issues with on/off removing event handlers that I don’t want to,

  • 0

I’ve been having issues with on/off removing event handlers that I don’t want to, and would like to namespace the event binding with the html element’s expando id.

function SomeWidget(el) {
   $(document).on('handler.MY_EXPANDO_ID', this.handler.bind(this));
};
var widget = new SomeWidget($(sometargetelement));

The problem with not having a unique identifier, is that currently I have namespaces the same, which screws up when I have two widgets of the same time, and one removed, it removed the handler for both objects.

Question 1) How do I access an elements’ internal expando id?
Question 2) Is there a better way to do this? Function.bind !== Function, which makes removing based on the actual method pointer not possible

I’m using jQuery 1.8.3

  • 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-16T11:54:13+00:00Added an answer on June 16, 2026 at 11:54 am

    jQuery UI’s widget factory increments a counter whenever a widget is created. Then they have an eventNamespace property available for exactly this reason. You could accomplish the same type of thing:

    function SomeWidget(el) {
        SomeWidget.instances++;
        var eventNamespace = ".SomeWidget" + SomeWidget.instances;
    
        $(el).on("handler" + eventNamespace, ...);
    }
    SomeWidget.instances = 0;
    

    This will increment the instances whenever a new SomeWidget is created. Internally it will have access to an eventNamespace that can be used for binding / unbinding events.

    If you needed access outside of your widget, you could store the eventNamespace as data on the element:

    $(el).data("eventNamespace", eventNamespace);
    

    However, this would be overwritten if you created multiple instances of the widget with the same element.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I have a French site that I want to parse, but am running into
I'm interested in microtypography issues on the web. I want a tool to fix:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to count the length of a string with PHP. The string
I have a jquery bug and I've been looking for hours now, I can't

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.