Git Product home page Git Product logo

Comments (3)

saadeghi avatar saadeghi commented on May 23, 2024

Hi @gjovanov,
Whenever checkbox is checked, drawer opens and whenever it's unchecked, drawer gets closed. There's no trick.

As you can see here I'm controling the drawer of daisy.js.org using the checkbox.
It's a Vue project tho. I'm not sure how Svelte works but if you manage to check/uncheck the checkbox somehow, it will work. Maybe your Svelte code is changing the virtual DOM somehow and is not effecting the actual checkbox. Unfortunately I don't have any experience with Svelte.

from daisyui.

saadeghi avatar saadeghi commented on May 23, 2024

@gjovanov Have you tried using bind:checked={checked} instead of checked={checked}
I found this example and it seems to only work with bind:checked

from daisyui.

gjovanov avatar gjovanov commented on May 23, 2024

Hey @saadeghi ,
thanks for the suggestion.

Svelte doesn't have a Virtual DOM and it's more like a Compiler that compiles the reactivity into Vanilla JS. But, indeed, the issue was related to Svelte specifics with the bindings.

bind:checked={checked} works whereat checked={checked} doesn't. Still no idea why.

But in case when using a writable store like this:

const checked = writable(false)

then both of them work (notice the $ sign in the binding):

<input id="my-drawer1" type="checkbox" class="drawer-toggle" checked={$checked}>

<input id="my-drawer2" type="checkbox" class="drawer-toggle" bind:checked={$checked}>

Anyways, sorry to bother you with issues not related to Daisy UI.

The good news there is a way to manipulate the state of components like drawer, accordion etc via the state if its checkbox.

Thanks again..

Closing...

from daisyui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.