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

Better way to link dirty attribute with other HTML elements #524

Open
gschurck opened this issue Mar 16, 2023 · 1 comment
Open

Better way to link dirty attribute with other HTML elements #524

gschurck opened this issue Mar 16, 2023 · 1 comment

Comments

@gschurck
Copy link

I have a search bar that mades request automatically on change with unicorn:model.

<div class="control has-icons-left is-large" unicorn:dirty.class="is-loading" id="search-div">
    <input type="text" class="input is-large" unicorn:model.debounce-200="search" unicorn:key="search"
           unicorn:dirty.class="is-loading"
           placeholder="{{ search_phrase_placeholder }}" id="meme-name">
    <span class="icon is-small is-left">
                <i class="fas fa-search"></i>
        </span>
</div>

I would like to set the class is-loading to the HTML div parent of the input element, to add a loading spinner while the request is processed on backend.
But with unicorn:dirty, I can only set a class on the input attribute.

So as a workaround solution I found this, and it works perfectly.

But it could be easier if we could target a specific id with dirty, to set the class wherever we want.

Is there any better solution ?
Thanks.

@adamghill
Copy link
Owner

Hmm, I do something sort of similar in this todo component, but it's with loading. If you can fork or make a small reproducible repo I can see why this might not be working as expected.

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

2 participants