5 ms·
Sweet Alert for Bootstrap – Blends nicely with any Bootstrap based project
- NDizzle 12y agoJust in time for Halloween! Scary, jarring alerts.
- deleted 12y ago[deleted]
- danneu 12y agoswal({ title: "Click outside to close", allowOutsideClick: true })
- csbrooks 12y agoVery slick!
- FreakyT 12y agoI usually find alert libraries boring, but these are really cool -- I particularly enjoy the icon drawing animations.
- akvlad 12y agoI agree this does look sweet, however this is not a replacement for alert. window.alert() is a blocking function, it prevents further code to be interpreted while the alert or prompt is open.
- cmpb 12y agoThere are of course more functional approaches to delaying execution of code in Javascript, e.g. by using a callback (which this library supports).
- jessedhillon 12y agoSweet Alert came up before and people made this same pedantic and unimaginative addition -- I honestly think this comment serves only to let everyone know that the commenter understands the Javascript execution model. That the thread stops while a native alert is shown is not quite a bug, but I'd argue not a desired feature either. But given that window.alert has (apparently) two functions: - Display a message to a user - Block javascipt execution until a button is pressed This is a great replacement for those who are using it for #1, which in my experience, is probably >99% of its usage in the wild. If you're using window.alert to, say, synchronize the beginning of an event with a user click this probably will work just fine too. If you need the world to stop until a button is pressed, I'd sooner guess that your application is written poorly.
- mnarayan01 12y ago> Sweet Alert came up before and people made this same pedantic and unimaginative addition Its presented as a replacement for alert so pointing out that it's not a drop-in replacement seems relevant to me at least. Even if most alert usages can easily be replaced by this (somewhat dubious depending on your definition of "easily"), additional work will still need to be done for many (most?) of them. Also being able to add a "blocking" call in JavaScript would be a _big deal_, so noting that this does not do so seems like something worth mentioning.
- j_syk 12y agoLooks cool. I'd like to see [esc] to close dialog. And is it a safe default to have [enter] perform the action especially on warning and danger? (just a thought)
- amatera 12y agoswal("Here's a message!") !== alert("Here's a message!") Am i wrong or is a replacement not something which replace the original function? (beside the blocking aspect of an alert). Looks beautiful anyway :)
- JoshTriplett 12y agoNice style, and I appreciate that I can hit Esc to dismiss most of the dialogs, though unfortunately not all of them. As another commenter said, I do wish that clicking outside of it had the same effect, but that may have more to do with what sites typically abuse these kinds of boxes for ("Alert! Sign up to our..." (no go away)). One issue I noticed: there's a race condition in the second-to-last example ('...and by passing a parameter, you can execute something else for "Cancel".'), where if you hit escape quickly enough as the box gets launched, the cancellation handler does not run.
- gadders 12y agoRe: your second point, on the original Sweet Alert page that this is based on it has this parameter: allowOutsideClick - If set to true, the user can dismiss the modal by clicking outside it.
- marknutter 12y agoIsn't this just a modal?
- deleted 12y ago[deleted]
- deleted 12y ago[deleted]
- iand675 12y agoThe icon animations are really slick!
- yournemesis 12y agoI still don't get why javascript developers put so much effort into a library and don't provide tests for it.
- deleted 12y ago[deleted]
- aidos 12y agoIt would be nice if it was possible to select / copy the message in the box. Sometimes you get a message that you want to copy / paste to someone (email, chat, etc) and it's annoying to have to type it out again.
- mandeepj 12y agoPlease have "Esc" key cancel\close the dialog box. It is the inherent behavior please do not break it.
- jcagalawan 12y agoSlight clipping issue http://imgur.com/TKAk41f http://imgur.com/TKAk41f
- michael_h 12y agoAnd some alignment problems: http://imgur.com/a/ZT6ip http://imgur.com/a/ZT6ip Edit: firefox 24.8.0
- mk4p 12y agoI met the most interesting guy once. He was a professor at Columbia and a consultant for Wall Street, helping design UIs for traders. He explained how we process and prioritize visual cues -- how, if an element expands equally to the left AND right of our field of vision, it gets highest priority because it resembles an object heading toward our face. For that reason, he avoided this design for everything except the highest-priority events. Not crapping on your library -- it looks really nice :) But in general, I think it's worth considering if it's necessary to demand users' attention all over the place. I think information overload isn't solely in the content we consume but how it's presented.
- coreymgilmore 12y agoThis is an eerily similar project to something posted a few weeks ago here. Most notably, the exact same "success" animation. https://news.ycombinator.com/item?id=8420902 https://news.ycombinator.com/item?id=8420902 https://github.com/t4t5/sweetalert https://github.com/t4t5/sweetalert
- michael_h 12y agoThird line on the link: This is just a clone for Bootstrap of the original SweetAlert.
- coreymgilmore 12y agoWow...my eyes must be going.
- shortstuffsushi 12y agoIt's a fork of the repo you mentioned, but with Bootstrap.
- decentrality 12y agoThis really needs to be added to http://jsdelivr.com http://jsdelivr.com so we can package it in with existing CDN calls. There seem to be very sparse examples of how to deploy the library properly, only to implement it. Visually great. Cool how there's the ability to catch responses and work in the same modal further.
- dangrossman 12y agoAnyone can add something to jsDelivr, not just the library author. You can add it yourself if you'd like them to host it.
- emodendroket 12y agoWhy would I use this instead of the built-in modals? Seems like it does the same thing.
- danneu 12y agoWhen you want a nice looking off-the-shelf feedback modal with a simple API without depending on Bootstrap JS and the entirety of jQuery.
- emodendroket 12y agoIn that case, why would I want a library that is specifically designed to work with Bootstrap?
- danneu 12y agoI'm pretty sure this library simply forks SweetAlert to use Bootstrap's markup and Less variables. So it comes out of the box plugging into Bootstrap CSS and your overrides (like, I imagine, a Bootstrap theme from bootswatch.com). I have a Bootstrap CSS + React app that uses React for everything I'd need Bootstrap JS for. The cost of Bootstrap JS is 9.9kb + 32.5kb (jQuery) = 42.4kb. Meanwhile, SweetAlerts JS weighs 3kb gzipped and comes with a simple API for exactly what I want to do.
- emodendroket 12y agoOK, that makes sense. Not my scenario but I can see the purpose now.
- execat 12y agoThe way the alert comes in is very annoying. The homepage doesn't tell me if I can customize the animation.
- warble 12y agoI've been seeing a few of these libs pop up on HN lately. Apparently there's some sort of need here that people are trying to fill, it's just not clear to me what it is. There are legitamite suggestions that blocking UI paradigms are bad, but they're very useful at times. I'm not arguing either, as I think each has their place (although I tend to avoid blocking personally if I can) My real question is why now?
- dangrossman 12y agoLots of people on HN develop web apps but aren't great designers, and nifty little libraries like this make our work look better than our own design skill would normally allow. I think it's that simple -- they're not being upvoted for any deep reason relating to UX best practices.