6 ms·
Not a replacement really; doesn't mimic the function signature, is not blocking as the alert etc etc
by hcho 12y ago
Not a replacement really; doesn't mimic the function signature, is not blocking as the alert etc etc
- colinramsay 12y agoIt's not possible for JS code to replicate the native blocking of alert(), prompt() and the like. Plus, if you call this with just one parameter, it does still work: sweetAlert('hello')
- kurumin 12y agoYes, is possible! https://github.com/al0p/wow-alert https://github.com/al0p/wow-alert
- Kiro 12y agoIs it blocking?
- reaktivo 12y agoFrom reading the source code I can say that no, it's not blocking. Although I'm not sure if there is an actual way of achieving that.
- Stratoscope 12y agoThere is no way for JavaScript code to implement the blocking behavior of alert().
- deleted 12y ago[deleted]
- scottcanoni 12y agoWhat I like about Wow Alert: 1. It's less than 5KB. 2. It overrides the existing alert function. 3. It extends the existing alert function. What I don't like about Sweet Alert: 1. It's bloated for what it does... > 30KB 2. The short-hand swal doesn't make sense or read well.
- deleted 12y ago[deleted]
- level 12y agoSweet alert is definitely bloated, but Wow Alert also depends on jQuery which is +80KB, so saying it's only 5KB is a bit deceptive.
- fro 12y agoChances are you are already have jQuery on your page though, right?
- teleclimber 12y agoNo. Modern sites usually depend on browser native dom methods and a Javascript utility belt, like underscore. Or some other combination of new stuff like angular or backbone whatever. But the "include Jquery in boilerplate" thing is not nearly as common anymore best I can tell.
- iLoch 12y agoAnyone who isn't using jQuery because "modern sites usually depend on browser native dom methods" is just being an asshole, honestly. If most big sites are using it, you can use it. I just checked: Twitter, Outlook.com, Stripe, Paypal, Pinterest, GitHub, Amazon, LinkedIn, Ebay, Tumblr, etc. The list goes on pretty much forever.
- zackboe 12y agoPeople are assholes because they prefer and use or don't use other libraries over a popular one? What?
- iLoch 12y agoI would always encourage using a library over not using one - if you're not using a library you're just going to end up making your own anyway to "save time" - might as well start with something everyone already knows. If your project is also going to be something that a lot of people touch, you don't want to be using your own solution or a lesser known solution just because it's neater - that would be a waste of time. So yeah, in my opinion if you opt to use your own solution or a lesser known one, I'd say you're at least a bit of an asshole because 1.) you're assuming you know better than the majority of people (who don't have a problem with using jQuery) or 2.) you're wasting everyone's time by forcing them to learn something new when there's a perfectly fine solution already available.
- RussianCow 12y agoI think what the parent meant is that it's not possible to make it blocking like the built-in alert function. WOW Alert still needs a callback if you want to do something after the alert is closed. So it's not a drop-in replacement.
- hcho 12y agoI know. I wouldn't call it a "replacement" if it's not behaviour compatible with the native function.
- arenaninja 12y agoIn which case I think the title is misleading as it is not a drop-in replacement. With that said, I think it looks great
- niutech 12y agoIt is possible to block JS execution using generators or an eval hack, see my showModalDialog polyfill: https://github.com/niutech/showModalDialog https://github.com/niutech/showModalDialog
- methodin 12y agoI still haven't found a really good use case for blocking UI - what are some?
- marquis 12y agoAny app that allows users to create content that is not stored in persistent storage: this will be lost if they close the window without saving in some manner. An example: an HTML5 audio recorder or photo editor.
- mikeryan 12y agoI'm not sure there's a great reason to block the UI with an Alert. But I also can't remember the last time I saw one except a really horrible AP tool by GXS which uses an alert to tell me my browser won't work on their site. (which of course it does once I switch my user agent string to one they like). Now this isn't a great use but its one maybe acceptable use if my browser really didn't work on their site. Confirm dialogs particularly around destructive actions are decent use cases for UI blocking.