Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a more individual event namespace #10848

Closed
phaidon opened this issue Sep 28, 2013 · 6 comments
Closed

Use a more individual event namespace #10848

phaidon opened this issue Sep 28, 2013 · 6 comments
Labels

Comments

@phaidon
Copy link

phaidon commented Sep 28, 2013

This issue is based on #8379 and #6921 and the request of @mdo to open a new issue for it.

Bootstrap 3.0 is using an event namespace, what is great. For example:
var e = $.Event('hide.bs.' + this.type)

But this namespace is not really individual. Because of the point it can be identical with the hide event of other libs. For example prototype (see #8379).

I know that bootstrap does not support other libs, but if it is using a namespace it would make sense to make it unique.

The solution could be to change the event name, eg, 'bs:hide.' + this.type (to use Backbone-inspired namespacing).

@cvrebert
Copy link
Collaborator

Such a change could not be made until v4 due to backward compatibility.

@phaidon
Copy link
Author

phaidon commented Sep 28, 2013

Such a change could not be made until v4 due to backward compatibility.

I already thought so. But it would be nice to keep it in mind for v4.

@ggam
Copy link
Contributor

ggam commented Sep 28, 2013

@cvrebert why not create a v4 milestone to group this kind of proposals?

@gschueler
Copy link

+1 i would like to see this fixed

@cvrebert
Copy link
Collaborator

Added to our internal v4 planning document.

@colllin
Copy link
Contributor

colllin commented Jun 16, 2014

I spent some time digging into the conflict with Prototype and the 'hide' event.

Here's an explanation of why it happens, which I just posted on stackoverflow:
http://stackoverflow.com/a/24236506/361609

I think there might be a solution --
We could prevent jQuery from calling Prototype's .hide() function if we called event.preventDefault(). The problem is, Bootstrap relies on event.isDefaultPrevented() to check if someone wants to cancel it's plugin functionality. So how can Bootstrap allow other people to call (or not call) event.preventDefault() but still make sure event.preventDefault() is ALWAYS called before the event chain finishes?

Maybe not so hard... I haven't tested this, it's just an idea:

Instead of (excerpted from tooltip.js):

var e    = $.Event('hide.bs.' + this.type)
// ...
this.$element.trigger(e)
if (e.isDefaultPrevented()) return

maybe something like

var e = $.Event('hide.bs.' + this.type)
// ...
e.preventDefault();
var isDefaultPrevented = false;
e.preventDefault = function() {
    isDefaultPrevented = true;
};
this.$element.trigger(e)
if (isDefaultPrevented) return

@twbs twbs locked and limited conversation to collaborators Jun 16, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants