-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
Alert dismissal change #1845
Alert dismissal change #1845
Conversation
…emoving the dom element. It's kind of wonky if one wants to show that alert again and it's completely missing.
Perhaps this might be better as an option you can set with something like |
If you want to just hide it when a user clicks the close button... just add an event handler and handle that: $('#myAlert .close').on('click', function () {
$('#myAlert').hide()
}) |
My problem is that the default action is counterintuitive. Close On Feb 8, 2012, at 23:58, Jacob Thornton
|
Spend few minutes wondering why I can't show my alert again after dismissing it...this might explain it. I agree with EricWarnke, this is stupid behavior and should be changed to hide instead. |
Same here, spent several minutes trying to get what was happening. Could this be changed to hide by default? Isn't it what most people would expect...? |
Yep - I hit this too. Can't see why removing should be preferable to hiding - it's no faster or easier and it's less flexible. +1 for hiding |
+1 for hiding... maybe the following to remove it (so non breaking change)
and the following to hide:
|
+1 for adding the option to hide. This will support reusable alerts without encoding them in JavaScript. I know it can be done in other ways, but less code will be used, and a similar design will be maintained, if the option to hide is available. Two tweak the comment above, presumably we will want the same
for the current behavior (removing the element upon dismissal), and:
to hide the element but retain it in the DOM tree. |
+1 for hide. I have a lot of resuable alerts in my code and this is adding a lot of bloat. I would agree with osuritz, for "data-hide" to not break existing behavior. |
I had this same problem, but the solution for it is pretty simple: just remove the attribute "data-dismiss" from the button. <button type="button" class="close">×</button> Then, as mentioned above, just bind the click function to a hide behavior> $('.alert .close').on('click', function () { $(this).parent().hide(); }) |
+1 for hide... It is indeed counter intuitive. Also the function should be changed from function removeElement() { to function hideElement() { Why would you have a 1 in a lifetime alert? Most likely this alert can happen again or even better, reuse the same component for different alerts. |
+1 for:
|
+1 for: data-hide="alert" |
👍 |
I agree with the pull request author: this is extremely counterintuitive. What's the point in deleting the alert from DOM altogether, when it can (and quite probably has to) be reused? |
👍 |
1 similar comment
+1 |
+1 for data-dismiss="alert" hiding. This is how Modals work and it's nonsensical that alerts do something completely different with the same button and attribute. One of our interns this summer thought to work around it by doing This pull request was made two years ago and has tonnes of comments. |
everything has been said |
FYI: This change cannot be made until Bootstrap v4 anyway, due to SemVer backwards-compatibility constraints. |
This isn't code code for it, anyway. The function removeElement() probably shouldn't simply hide the element. |
there are a handful of better ways to handle to this problem. If you don't want to use "hide" yourself, you should just store a reference to the alert - we don't kill that. Here's a simple example: http://jsbin.com/sodunowuho/1/ |
Hi @fat! You appear to have posted a live example (http://jsbin.com/sodunowuho/1/edit), which is always a good first step. However, according to Bootlint, your example has some Bootstrap usage errors, which might potentially be causing your issue:
You'll need to fix these errors and post a revised example before we can proceed further. (Please note that this is a fully automated comment.) |
good looking out twbs-bot |
@fat While that works, it just doesn't make sense that bootstrap is removing an element from the DOM. I'm impressed that this is being revisited three years later, but nobody has stated why removing the object from the dom is the preferable solution to hiding it. I feel like most people (in fact, everyone prior that had commented on this issue) agree that hiding should be the default, with removing from dom available either through bootstrap options or dev intervention. It's the difference between having to intercept default functionality and change it, and having to listen for default functionality and perform additional functionality. |
Personally I don't mind the removal and never have. Rather than a default behavior change I'd rather just see a hide or remove option so it decides what to do based on what you tell it. |
Few thoughts on it:
That's coming from someone who's not writing much JS mind you, but look at it from a user experience and designer point of view. |
@mdo An immediate thought is a warning or info level alert caused by JavaScript. The user does something wrong, you show an alert. They click the X, they do the same thing, and .. suddenly there's no alert to re-show. It is not the CSS framework's job to keep the DOM clean. Only to render it as the code says, is my opinion, personally. |
Yeah my similar use case was imagine a delete button for a record. That button is associated with a modal to confirm the deletion. Use dismisses (thus canceling the delete operation). Now if they click the same delete button, the same dialog should presented. On Tue, Jun 9, 2015 at 7:55 PM, Navarr Barnier notifications@github.com
|
However, Bootstrap is more than just a CSS framework, as clearly the issue you're having here is how Bootstrap's JavaScript components behave. |
Changed the alert dismissal from remove() to hide(). It's kind of wonky if one wants to show that alert again and it's completely missing from the DOM.