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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:42:21+00:00 2026-06-14T06:42:21+00:00

jQuery events have a namespace concept built in for easy and safe unbinding of

  • 0

jQuery events have a namespace concept built in for easy and safe unbinding of just the events you’ve added.

These namespaces, however, don’t prevent collisions when different plugins trigger the same basic event. For example, if plugin A triggers the hide.foo event and plugin B triggers the hide.bar event, any handler listening for the hide event is going to be invoked twice, even with the namespaces.

This can cause problems when plugins trigger overly generic names like open, close, show, hide, start, end, etc., yet so many plugins out there (even ones from large libraries like jQueryUI and bootstrap) trigger these generic events without a second level namespace.

So here’s my question. It seems like a second level of namespacing would be prudent, both to distinguish your events from other plugins and from standard DOM events. The convention could be something like namespace:eventName or namespace:eventName.secondaryNamespace if using the standard jQuery dot notation.

But nobody seems to be doing this, so I wonder if there’s some compelling reason not to. Does anybody know?

Update:

To provide a more concrete example, suppose I’m using plugin A which triggers the show and hide events on tooltips as the user hovers over certain text. Since events propagate and my DOM is constantly changing, I decide to bind my event listener to the document element to catch the show and hide events from all tooltips.

Then, a few weeks later, I add plugin B to my app which also triggers the hide event after the user dismisses an alert message. Now all of the sudden my tooltip code is going to be invoked more than I want it to because both the tooltip and the alert message plugins are triggering events with the same name.

  • 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-14T06:42:22+00:00Added an answer on June 14, 2026 at 6:42 am

    It turns out that both libraries I specifically mentioned (jQueryUI and Bootstrap) either do or are planning on prefixing their custom events.

    Here’s what jQueryUI does in its custom _trigger method:

    event.type = ( type === this.widgetEventPrefix ? type : this.widgetEventPrefix + type ).toLowerCase();
    

    This allows you to define your own prefix via this.widgetEventPrefix on any included widget or widget you make with the widget factory.

    Bootstrap hasn’t implemented a prefix yet but plans on doing it in the next major version (3.0.0).

    Here is what @fat said in this Github issue:

    In the future we’ll probably namespace everything with bootstrap
    (data-attrs and events – but that will be a 3.0.0 thing, because it’s
    breaks backwards compatibility)

    And here is his tweet in response to my question about it.

    —

    As for me, I’ve decided to name my custom events with one of the following patterns (depending on context) to avoid any possible conflicts with other libraries in the future.

    prefix:event.namespace
    appname:widgetname:event.namespace
    libraryname:widgetname:event.namespace
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some trouble with jquery ui-events: In my application, there are some sliders.
Possible Duplicate: Bind multiple events to jQuery 'live' method I have the following function:
I have some onchange events setup in jQuery which are used to populate a
I have several onmouseover events (combination of javascript functions and jquery accordions) but they
I am developing an events page using jquery mobile. I have a stylish way
I have binded jquery events set for mouseenter mouseleave, as well as jquery draggable.
I have created a series of custom jQuery events for use in mobile web
Hello I have a form with a button and link jQuery events. I am
I have a series of anonymous jQuery/javascript functions for click events which have to
I have a radio group that allows the user (using jQuery events) to deselect

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.