Skip Navigation

[Resolved] Frontend Events and JavaScript – how can I get the ID selected?

This support ticket is created 7 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 7 years, 11 months ago.

Assisted by: Nigel.

Author
Posts
#403564

I've got a parametric search set up in my view to let people filter by topic (topic is a taxonomy) using checkboxes.

Whenever someone checks a checkbox, I need to get it's ID. So I added a frontend event handler that gets called whenever The parametric search data has been collected.

That gives me a function - I can put an alert() in it and see that it's getting called. But I don't understand how to know what information is being passed in. How can I get the ID of the item the user just selected?

I tried data.view_unique_id but that returns the same value every time, regardless of which item was checked.

Thanks,
Abby

#403672

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

For the front end event, choose Parametric search > The parametric search has been triggered.

The checkboxes have id's such as "in-category-10" etc. and you can retrieve it from the data object with data.form.context.id. (If you console.log(data) then you can navigate the object in your browser console to see what information is available.)

So this will log the id each time someone clicks on the checkboxes:

jQuery( document ).on( 'js_event_wpv_parametric_search_triggered', function( event, data ) {

  	console.log(data.form.context.id);
});
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.