Answer the question
In order to leave comments, you need to log in
How to make a filter on Vue.js on click?
There is a live filter using Vue2Filters. The value from v-model is substituted into the filterBy() function.
Is it possible somehow to apply the filter only when the "FILTER" button is clicked?
input(type="text",class='filter_tags form-control',v-model="input",autofocus='')
button.searchBtn(type="button") ФИЛЬТР
br
table(:id="getTableClass")#table-tagsdata.table.table-tags.table-bordered
tr
th(v-for='tth in tagshead') {{tth}}
template(v-for='tagObj in filterBy(tagsdata, input)')
Answer the question
In order to leave comments, you need to log in
You can add another variable to the component's data and assign it a value from the input in the button handler:
Here
template(v-for='tagObj in filterBy(tagsdata, input)'
change totemplate(v-for='tagObj in filterBy(tagsdata, some_value)'
Okay, thanks Evgeny Kulakov ! To get a working filter on click, I did this:
in the template, I left the input
in the search field in the v-model directive put the property of the data object - search_value
I also added the input property to data and it turned out:
data: function() {
return {
search_value: '',
input: ''
};
}
input.searchBtn(type="button", v-on:click="input=search_value", value="ФИЛЬТР")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question