1

I have a nested v-for in my html, and in every iteration I need to apply filter. The filter itself is the same, but it should work only in current iteration.

For now, my v-for looks like this (it's also Laravel Blade templating, that's why I need these @):

<div class="col s4" v-for="(ind, campaign) in campaigns">
    <select class="select-class" v-model="tags_filter_@{{ind}}" multiple style="height: 150px;">
        <option value="">all</option>
        <option v-for="tag in tags" value="@{{tag.title}}">@{{tag.title}}</option>
    </select>

    <select v-model="campaign.selectedWebsites" multiple class="mdc-select__surface select-class" style="height: 300px;" id="web_select_@{{ind}}">
        <option v-for="(index, website) in websites | filterBy tags_filter_@{{ind}}" id="website_@{{ind}}_@{{website.id}}" value="@{{website.id}}">@{{website.url}}</option>
    </select>
</div>

And it doesn't work. I need websites in each campaign to be filtered by their own tag select. But if I remove _@{{ind}} from v-model and filterBy, logically it becomes the same model everywhere, and works on all iterations at the same time.

How can I fix it?

1 Answer 1

1

I changed @{{ind}} to [ind] in v-model and filterBy, and it worked out.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.