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

481 remove element #483

Merged
merged 34 commits into from
Jan 25, 2024
Merged

481 remove element #483

merged 34 commits into from
Jan 25, 2024

Conversation

g105b
Copy link
Member

@g105b g105b commented Jan 8, 2024

Closes #481

Docs:

Removing elements with a boolean modifier

It's possible to remove an element from the document when a certain condition is true/truthy by marking the element with the data-bind:remove attribute. If the boolean modifier is triggered, the element will be removed from the document.

The inverse logic can be applied by adding an exclamation mark (!) to the start of the bind value.

In this example, a bound object has an isDay boolean property, and the appropriate span is removed from the document, leaving the correct sentence behind:

<p id="day-or-night">Is it day or night? <span data-bind:remove="?isDay">It's nighttime!</span><span data-bind:remove="?!isDay">It's daytime!</span></p>

If the bound object has a truthy isDay property, the span containing "It's nighttime" will be removed, and the span containing "It's daytime" will persist.

g105b added 30 commits July 24, 2022 20:24
@g105b g105b merged commit 143aa97 into master Jan 25, 2024
7 checks passed
@g105b g105b deleted the 481-remove-element branch January 25, 2024 10:27
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

Successfully merging this pull request may close these issues.

Remove element using boolean bind key modifier
1 participant