Forum Discussion
I have a way to detect the current sort order using javascript. I have added the following to my component and this seems to work fine!
<#-- Hide the thing if the sort order is not Oldest to Newest -->
<script>
const sortObserver = new MutationObserver((mutations, obs) => {
const sortMenu = document.querySelector('.lia-thread-sort-menu');
if (sortMenu) {
const divToHide = document.getElementById('highlighted_section');
const sortOrderOldtonew = sortMenu.querySelector('[aria-label="Van oudste naar nieuwste"], [aria-label="Oldest to Newest"]');
if (!sortOrderOldtonew && divToHide) {
divToHide.style.display = 'none';
}
obs.disconnect();
return;
}
});
sortObserver.observe(document, {
childList: true,
subtree: true
});
</script>
This searches for the id #actionMenuDropDown_4, inside class .lia-thread-sort-menu. If this doesn't exist drop down option#4 is not currently set and thus my target div is hidden.
Claudius I am still curious if you found a better way to detect the current sort order.
I couldn't find any context object or API call returning the sorting reliably, unfortunately 😐 So your client side solution seems to be the only feasible way so far.
- Hoekstra_VFZ3 years agoAdvisor
Thanks, yeah the only thing we can retrieve out of the API are the initial settings, not the dynamic current setting of the sort order.
Because the OOTB display for the solution/best answer is working fine based on the dynamic sort order I still think there is some trick only Khoros knows about.
Related Content
- 7 months ago
- 2 years ago
- 4 years ago
- 10 months ago