Tell us what you are trying to do?
I'm trying to figure out how to hide empty search dropdowns. I made a custom JS it works in itself but not how well inside WP.
Is there any documentation that you are following?
Not really, it's just custom JS code, I haven't found what I needed looking through toolset docs.
Is there a similar example that we can see?
an already working one: hidden link
What is the link to your site?
hidden link
So, the idea behind my JS is to use a foreach to target the select, see if they're empty or not if they are remove them.
The JS in itself works, as we can see in this fiddle: hidden link
And I cant make it work badly in WP, but I need a reliable way of hitting the length or values of the selects. As of right now .length works in the fiddle and doesn't work in WP, .value works in WP but then it also removes the unselected choices in other populated dropdowns.
Hello,
You are using AJAX search feature, please try trigger your custom JS codes with JS event "js_event_wpv_parametric_search_results_updated", for example:
jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) {
/**
* data.view_unique_id (string) The View unique ID hash
* data.layout (object) The jQuery object for the View layout wrapper
*/
// Here setup your custom JS codes
});
Hey!
It's still not working. I tried an example of the HTML (the actual one) in codepen and it works kinda, I guess it needs some polishing, but still, even using the jquery event doesn't work.
hidden link
I've made it somewhat work.
The issues is as follows now since the triggers don't seem to be working:
First, the grid doesnt change when things are missing, if say X X X X Y X X it will only show a whitespace in Y. (should I be targeting a differente div? I'm targeting the grid cell already)
Second, even with the AJAX triggers, when you filter something all the removed grid cells come back, which is intended what's not intended is that the code doesn't retrigger and remove them again.
Any help would be appreciated
According to our support policy, we don't provide custom codes support:
https://toolset.com/toolset-support-policy/
The JS event "js_event_wpv_parametric_search_results_updated" is triggered after you make a AJAX search
The JS vent Query(document).ready will be triggered after the page loaded, so you will need to trigger your custom JS codes twice:
- the page loaded
- user makes the AJAX search
Hope it helps
I don't need code support, the code works perfectly. What I need is support in regards to Toolset.
I can't see how this is isn't solely related to Toolset blocks. I'm looking to know what to target, not for you to make the code for me.
As I've said even with the toolset triggers, the code doesn't refire.
I'm using both document.ready for the incial load and:
jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) for after the AJAX load but it doesn't retrigger.
In the previous toolset version, in Views and plain HTML without using Blocks, it was simpler to target html and have expected behaviour but now with blocks I cant tell what to trigger. Should I maybe change from Grids to Containers? Idk. But this is 100% related to toolset, if you want ignore the code, which works.
The support policy:
"We cannot produce custom code solutions for you. When you need custom coding which extends Toolset functionality, we recommend contacting one of Toolset certified consultants."
I have made the code already.
I have tried the JS event "js_event_wpv_parametric_search_results_updated" in my localhost with a fresh WP installation + the latest version of Toolset plugins, it works fine after the AJAX search results are updated, if you need more assistance for it, please provide a test site with the same problem, also point out the problem page URL and view URL, I can setup a demo for you.
With the standard JS even didn't work, but with:
document.addEventListener("DOMContentLoaded", ejecutar);
jQuery( document ).on( 'js_event_wpv_parametric_search_form_updated', ejecutar);
at the end of the code, works like a charm.