Skip Navigation

[Resuelto] Reset Button breaks my jQuery .click function

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:
Reset button breaks the filter view and clear the jquery script from the DOM.

Solution:
Use the following jQuery in View >> JS editor:

 
jQuery(document).ready(function($){
    $(document).on('click', '.FilterTopLevel-trigger', function(){
        $(this).next().toggleClass("ShowOptions");
        $(this).toggleClass("TriggerSelected");
        $('.FilterTopLevel-trigger').not(this).next().removeClass("ShowOptions");
        $('.FilterTopLevel-trigger').not(this).removeClass("TriggerSelected");
    });
      
    $(document).on('click', '.FilterSubmit', function(){
        $(".FilterTopLevel-trigger").next().removeClass("ShowOptions");
    }); 
});
This support ticket is created hace 7 años, 3 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Este tema contiene 5 respuestas, tiene 2 mensajes.

Última actualización por nicholasM hace 7 años, 3 meses.

Asistido por: Noman.

Autor
Mensajes
#560655

I have some custom jQuery .click functions on my filter taxonomy terms, everything works when searching, you can search, adjust search and search again everything works, when I click the "Reset" filters button the onlick function is removed from my code.

I have the .click function wrapped in a doc ready function, something in the Ajax reset is clearing my script from the DOM it doesnt show in inspector as attached to the element after the reset

#560847

Noman
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Karachi (GMT+05:00)

Hi Nicholas,

1. Can you please provide link to the page where we can see this issue? Also please make sure that you are using latest version of Toolset plugins.

2. I assume you have added the jQuery in the Views >> JS editor. Please provide the jQuery code you are using at moment.

Please note that we do not debug custom code (custom jQuery, php, js, etc) related issues, as such it is out of our support as per support policy, but i will give it a look and see if I can find any reason & provide something:
https://toolset.com/toolset-support-policy/

Thank you

#560942
trigger.PNG

Ok I have pushed the site to a dev server so you can see the issue. I understand that you do not troubleshoot custom code, however the reset button seams to be causing the issue.

so if you click on a category you will see the onclick script work, then you can search and still change categories, however use the reset button and the onclick function is wiped clean out of the dom.

I had the JS in a custom scripts file however I did also try it inside the views editor

$(".FilterTopLevel-trigger").click(function(){
  $(this).next().toggleClass("ShowOptions");
  $(this).toggleClass("TriggerSelected");
  $('.FilterTopLevel-trigger').not(this).next().removeClass("ShowOptions");
  $('.FilterTopLevel-trigger').not(this).removeClass("TriggerSelected");
});

$(".FilterSubmit").click(function(){
  $(".FilterTopLevel-trigger").next().removeClass("ShowOptions");
});

enlace oculto

#561270

Noman
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Karachi (GMT+05:00)

Thank you for providing more details and the jQuery code. Our forum is loaded with more tickets than usual. I am going to analyse this and will update you with my findings soon.

Thank you for waiting.

#561348

Noman
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Karachi (GMT+05:00)

Here is updated jQuery, please try to use this and it will resolve the issue:

jQuery(document).ready(function($){
	$(document).on('click', '.FilterTopLevel-trigger', function(){
		$(this).next().toggleClass("ShowOptions");
		$(this).toggleClass("TriggerSelected");
		$('.FilterTopLevel-trigger').not(this).next().removeClass("ShowOptions");
		$('.FilterTopLevel-trigger').not(this).removeClass("TriggerSelected");
	});
	 
	$(document).on('click', '.FilterSubmit', function(){
		$(".FilterTopLevel-trigger").next().removeClass("ShowOptions");
	});	
});

Thank you

#561402

AWESOME! Thanks a lot for taking a look at that for me, works perfect.