Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"If" functionality which remove/add element from the DOM #504

Open
matndev opened this issue Dec 20, 2023 · 0 comments
Open

"If" functionality which remove/add element from the DOM #504

matndev opened this issue Dec 20, 2023 · 0 comments

Comments

@matndev
Copy link

matndev commented Dec 20, 2023

I would like to replicate the ngIf directive from Angular in hyperscript.

To do that I need to remove or add from DOM elements based on a condition.

But I didn't find a manner with hyperscript currently.

Here an example code to begin with :

<div _="set global currentItem to 0">

        <div **for loop with index **>
            <div class="element**index**"">
                <p>Hello world</p>
            </div>
        </div>

        <button _="on click show :currentItem and remove others then halt the event">
</div>

The idea is to hide/show (by removing or adding) element depending its index. If the index is equal tu currentItem it shows the element otherwise it is removing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant