Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> The biggest thing though, is for the life of me I don't understand why you can't open and close a dialog without JavaScript. There's no way to do it.

You can use popovers like this without JavaScript:

    <button popovertarget="some-element" popovertargetaction="show">Open</button>
    
    <div id="some-element" popover="auto">
        <button popovertarget="some-element" popovertargetaction="hide">Close</button>
    </div>

You can mark a <dialog> element as open by default with the `open` attribute, and you can close it with a button using the `dialog` form method. No JavaScript required for that either.

I don’t think there’s any way at present to open a `<dialog>` element specifically without JavaScript, but command/commandfor handles this and was recently added to the HTML specification:

https://github.com/whatwg/html/pull/9841



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: