Skip Navigation

[Resolved] Sort control doesn't trigger js_event_wpv_parametric_search_results_updated

This support ticket is created 4 years, 3 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by Maximiliano Mendieta 4 years, 3 months ago.

Assisted by: Shane.

Author
Posts
#1801227

I have a view that list my woocommerce products, in that view I use a shortcode attribute (catrel) to show some products in diferent pages according to certain category: all the categories on the parent page (Obras), and only one category on the child pages (Contemporaneas, etc.).

The problem is when I try to sort the results on a page with the shortcode attribute seted to a category name (on any of the child pages of Obras) the "js_event_wpv_parametric_search_results_updated" is never triggered, it seems that the ajax request is never happen, I also checked the browser console, on the network tab and there is no post request maded when i change any sorting option. The "js_event_wpv_parametric_search_triggered" event works well.

My "Custom Search Settings" are these:
- Let me choose individual settings manually

+ Update the View results every time an input changes

+ Show only available options for each input

#1803251

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2020-10-07 at 9.57.28 AM.png
Screenshot 2020-10-07 at 9.56.50 AM.png

Hi Maximiliano,

Thank you for getting in touch.

This actually works fine for me on my end.

This is the code i'm using to test.

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
	*/
	console.log('results updated')
});

Secondly here is a screenshot of my form.

Finally my next screenshot shows the results in my website console. As you can see it's working fine.

Ensure that your sorting controls are within the [wpv-filter-controls] [/wpv-filter-controls] shortcode.

Thanks,
Shane

#1803337
sorting-on-parent-page.jpg
sorting-on-child-page.jpg

Hi Shane, thanks for your response.

If you go to hidden link and use the sorting options (Ordenar por) it works well. The problem is at the child pages, for example: hidden link

When I try to use the sorting controls the results update doesn't trigger (the filters works well, actually if I change the sorting and, after that, apply a filter then the results are updated).

In the images you can see the console logs that I'm using to know if the event is triggered or not. On the parent page the results update is working (two logs), but on the child page I only get the "search triggered!" log.

Let me know if you need access to the site.

I have the [wpv-filter-controls] shortcode wrapping the filters and the sorting controls, but maybe I'm missing something. Here's the code of the "Search and Pagination":

<div class="wrapperFiltersSort">
	[wpv-filter-start hide="false"]
		[wpv-filter-controls]
			<div class="wrapperFilters">
				<p class="bread"><a href="/obras">Obras</a> <span></span></p>
				<a class="triggerFilters" href="#this">filtrar</a>
				<div class="filters">
					<div>
						<div class="form-group">
							<label for="wpv-pa_disciplina">Disciplina</label>
							[wpv-control-post-taxonomy taxonomy="pa_disciplina" type="checkboxes" url_param="wpv-pa_disciplina"]
						</div>
						<div class="form-group">
							[wpv-control-post-taxonomy taxonomy="pa_formato" type="checkboxes" url_param="wpv-pa_formato"]
						</div>
						<div class="form-group">
							[wpv-control-post-taxonomy taxonomy="pa_orientacion" type="checkboxes" url_param="wpv-pa_orientacion"]
						</div>
						<div class="form-group">
							[wpv-control-post-taxonomy taxonomy="pa_estilos" type="checkboxes" url_param="wpv-pa_estilos"]
						</div>
						<div class="form-group">
							[wpv-control-post-taxonomy taxonomy="pa_temas" type="checkboxes" url_param="wpv-pa_temas"]
						</div>
						<div class="wrapperFilterArtistas">
							<a class="triggerFilterArtistas" href="#this">filtrar por artista</a>
							<div class="filtersArtistas">
								<div>
									[wpv-control-post-relationship ancestors="artista@artista-obra.parent" url_param="wpv-relationship-filter"]
										<div class="form-group">
											[wpv-control-post-ancestor type="checkboxes" ancestor_type="artista@artista-obra.parent"]
										</div>
									[/wpv-control-post-relationship]
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="wrapperSort">
				<p>Ordenar por</p>
				<select name="wpv_sort_orderby" class="wpv-sort-control-select wpv-sort-control-orderby js-wpv-sort-control-orderby" data-viewnumber="96" autocomplete="off">
				<option value="post_date" data-orderbyas="string" data-forceorder="desc">más nuevo</option>
				<option value="field-views_woo_price" data-orderbyas="string" data-forceorder="desc">mayor precio</option>
				<option value="field-views_woo_price" data-orderbyas="string" data-forceorder="asc">menor precio</option>
			</select>
			</div>
			<div class="clear"></div>
		[/wpv-filter-controls]
	[wpv-filter-end]
</div>
#1803557

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Maximiliano,

The issue isn't that the code isn't working.

The problem seems to be that the results are not being displayed after you've triggered the ordering.

For me it just loads indefinitely.

Once the results load then the code should get triggered. However we need to understand why the view isn't loading the results.

Are these two views the exact same view ? I've enabled the private fields so that you can provide the credentials.

Please let me know.
Thanks,
Shane

#1804903

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Maximiliano,

The issue is actually with your sorting controls here

 <select name="wpv_sort_orderby" class="wpv-sort-control-select wpv-sort-control-orderby js-wpv-sort-control-orderby" data-viewnumber="96" autocomplete="off">
                <option value="post_date" data-orderbyas="string" data-forceorder="desc">más nuevo</option>
                <option value="field-views_woo_price" data-orderbyas="string" data-forceorder="desc">mayor precio</option>
                <option value="field-views_woo_price" data-orderbyas="string" data-forceorder="asc">menor precio</option>
            </select>

Once I added the default sorting option shortcode for Toolset it works perfectly fine, so I would recommend using this instead of using the written out HTML.

If you check the pages now the sorting should be working fine as well as triggering the custom code.

Thanks,
Shane

#1804995

Hi Shane, thanks for your help!

I changed the select for the default sorting shortcode and now it works in all the pages.

Have a nice day!