Hi! Is it possible to trigger category change action on search page. My case: I have a list of categories at the top
and when I click on them the results at the bottom should change according to the category. I made a connector search-categories, and added a connector class in search-categories.js. But it doesn’t work when I do this way
const tt = require('discourse/components/search-advanced-options');
const Category = require("discourse/models/category");
const Component = require("@ember/component");
const I18n = require("I18n");
const { action } = require("@ember/object");
const { escapeExpression } = require("discourse/lib/utilities");
export default {
setupComponent(args, component) {
component.set('today', new Date());
console.log('setup')
},
@action
onChangeSearchTermForCategory(categoryId) {
if (categoryId) {
const category = Category.findById(categoryId);
tt.onChangeCategory && tt.onChangeCategory(category);
tt.set("searchedTerms.category", category);
} else {
tt.onChangeCategory && tt.onChangeCategory(null);
this.set("searchedTerms.category", null);
}
tt._updateSearchTermForCategory();
},
}
Why it doesn’t work and what can be done. My connector hbs file
<div class="custom-categories-wrapper">
{{conditional-loading-spinner condition=loadingCategories}}
<div class="nav-pills">
{{#each categories as |cat|}}
<li>
<a data-slug="{{cat.slug}}" {{on "click" @onChangeSearchTermForCategory cat.id}} data-id="{{cat.id}}">{{cat.name}}</a>
</li>
{{/each}}
</div>
</div>