-5

Is there a Vanilla JS replacement for the dialog widget provided by jQuery UI? It should at least allow to contain arbitrary markup, so alert or prompt are not an option.

5
  • 2
    alert, prompt, confirm Commented Nov 20, 2018 at 15:10
  • 1
    The internet is full of javascript dialogs/light boxes. Commented Nov 20, 2018 at 15:12
  • 1
    There's the native HTML5 <dialog> element but it's not supported on several important platforms.
    – Pointy
    Commented Nov 20, 2018 at 15:12
  • 1
    I'd suggest making one. It is very easy to do, and should take no more than about 30 minutes. I'd suggest creating a few funcs. One func to hold your structure, with a param to feed your content and any conditions with the dialog you need. Another func for events, such as your click events, scrolling, loading, drag, resize, etc. And a 3rd possibly for any ajax you may need. You may even want a 4th depending on how you handle initializing the modal. Lastly, your CSS. A simple modal will have a basic HTML structure - usually a title bar, content body, and if necessary, a footer.
    – Pegues
    Commented Nov 20, 2018 at 15:18
  • 1
    If you want a lightbox, the approach is similar to the modal, except that you don't usually want things like drag, and it usually has a backdrop. Otherwise, the approach is very similar.
    – Pegues
    Commented Nov 20, 2018 at 15:19

1 Answer 1

0

Only to a certain extend. You might use alert, prompt or confirm dialogs (implemented as functions on the window object), but they can't be styled and look different between various browsers.

Creating a special modal/dialog with vanilla JS is of course possible. How hard it is depends on the features you want/need it to have.

Not the answer you're looking for? Browse other questions tagged or ask your own question.