Skip Navigation

[Closed] JQuery in custom search gets broken when searching

This support ticket is created 3 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 3 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#1916711

a.R

Hi again.

On this site, we have a custom search form on the left.
After reload, everything is fine, incl. the JQuery that deactivates in "... Fächer" one option ("Kern"/"Rand",...) when activating another option of the same subject (Fach). (See what I mean?)
After firing the search once or twice, JQuery seems to be broken.

Can you tell me why?

Thank you, kind regards,

Achim

#1916725
Screen Shot 2021-01-24 at 2.55.36 PM.png

If the custom jQuery manipulates filters, you may need to trigger it again after the filters update. When results are updated, typically the filters are overwritten as well so any options you changed before update may need to be changed again. We have a couple of JS events available for you to use as "hooks" to trigger your custom code. In the legacy View editor's Search and Pagination editor, you will find a JS panel. Open the panel, and you will find a Front-end JS events button. Click that button to generate the appropriate event hook syntax. For example, the event hooks fired when the search form is updated (input update automatically when filters change) and when the search results are updated:

jQuery( document ).on( 'js_event_wpv_parametric_search_form_updated', function( event, data ) {
	/**
	* data.view_unique_id (string) The View unique ID hash
	* data.view_changed_form (object) The jQuery object for the View form after being updated
	* data.view_changed_form_additional_forms_only (object) The jQuery object containing additional forms from other instances of the same View inserted using the [wpv-form-view] shortcode
	* data.view_changed_form_additional_forms_full (object) The jQuery object containing additional forms from other instances of the same View inserted using the [wpv-view] shortcode
	*/
	// add your code here
});
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
	*/
	// add your code here
});

If using the Blocks Editor to design your View, you can copy+paste the code examples above in the View's custom JS panel, since there is no Front-end Events button to generate the code automatically.

#1921049

a.R

Hi Christian,

we´re looking into this.
Probably takes some days - sorry.

Thank you, kind regards,

Achim

#1921051

Okay I will stand by for your update.

The topic ‘[Closed] JQuery in custom search gets broken when searching’ is closed to new replies.