Tell us what you are trying to do? Using jQuery, show the result when the user click submits/reset.
I have multiple views on one page.
On one of the views [Global - States] - State Action, I use a basic jQuery to hide/show the result. I use frontend events: "js_event_wpv_parametric_search_form_updated", so when the form is Submitted or Resetted it will show the results. This function works just fine.
The problem occurs when I click reset on other views [Legislation - state] - Recent Legislation, the result on the previous view [Global - States] is unhiding.
On page load, I hide the result on the top view using display: none.
When users click submits/reset on the top view, it triggers the jQuery to show the result.
--- so far it's working just fine ---
When users click reset on the bottom view, the result on the top view did not suppose to show/display.
For some reason, the reset button on the bottom view; triggers the top view to show/display the result.
hidden link hidden link
Below is the script that I'm using on the top view:
function hide_result() {
jQuery("#global-states").hide();
jQuery("#hide-section").hide();
jQuery("#pagination-global-states").hide();
};
function show_result() {
jQuery("#global-states").show();
jQuery("#hide-section").show();
jQuery("#pagination-global-states").show();
};
Since it is a custom codes problem, please provide a test site with the same problem, fill below private message box with test site credentials, I need to test it in a live website. Thanks
I assume you are going to not trigger you custom JS function show_result() when user click on "Reset" button of view Legislation - State (view# 17743).
If it is, I have done below modifications in your website:
Edit view "Global - States" ID:47151, in the "JS Editor", line 20, add below JS codes:
Yes, it's working like what I wanted.
May I know where you get the value 'TCPID17684'? Is it site-specific? Can I use the same info to exclude more views from triggering the jQuery?
The other views are 44304 (Statute) & 17741 (Litigation - State)
With the code above, the views 17741 (Litigation - State) - tab "Key Litigation" is working.
But the views 44304 (Statute) - tab "Enacted Laws" didn't work. It still triggers the jQuery to shows results.
That ID is specific by View's search form, different view in different page will be different value. You can get it by edit your JS codes, from:
jQuery(document).on( 'js_event_wpv_parametric_search_form_updated', function( event, data ) {
...
});
jQuery(document).on( 'js_event_wpv_parametric_search_form_updated', function( event, data ) {
console.log(data);
...
});
Then goto front-end, for example: hidden link
click the button "Reset", you will be able to see the values of data in your browser console window, and find the specific IDs.
see screenshot console-log.JPG