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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS: showOnlyWhen() #5490

Closed
wants to merge 1 commit into from
Closed

Conversation

faissaloux
Copy link

@faissaloux faissaloux commented May 22, 2024

Helloooo 馃憢馃徎

Summary

Since we usually on the case where we show/hide elements depending on some condition. In this PR I have added a new method showOnlyWhen() that will simplify this more.

Example

Before

const checkbox = $("#the-checkbox");
const otherElem = $("#the-other-element");

if (checkbox.attr("checked")) {
    otherElem.show();
} else {
    otherElem.hide();
}

After

const checkbox = $("#the-checkbox");
const otherElem = $("#the-other-element");

otherElem.showOnlyWhen(checkbox.attr("checked"));

Checklist

If approved I'll be happy to add documentation for it.

Copy link

linux-foundation-easycla bot commented May 22, 2024

CLA Signed


The committers listed above are authorized under a signed CLA.

@mgol
Copy link
Member

mgol commented May 22, 2024

Thanks for the contribution but this can easily be done as a userland plugin. The "Before" version is not that complex either.

See:

@mgol mgol closed this May 22, 2024
@faissaloux faissaloux deleted the showOnlyWhen branch May 23, 2024 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants