A
A
alexiusgrey2021-11-18 15:58:14
AJAX
alexiusgrey, 2021-11-18 15:58:14

How to properly close the "great-grandfather" of a particular current checkbox after a change?

find doesn't work, I tried.
In general, there is a list with checkboxes for product categories and attributes, for filtering. When you click on the title of a category or a specific attribute, this list opens, by default it is hidden. More or less like this

jQuery('.side-nav>h5').on( "click", function() {
  jQuery(this).parent('.side-nav').children('.st-accordion').slideToggle();
  jQuery(this).children('span').toggleClass('rotate');
});


This is how it works, no, through find, I would not have fenced two points instead of one.
When you click on the color-size-category you like, a large ajax filter is launched, the trigger is change.
$('.side-nav>.st-accordion>ul>li input').on('change',function(e){ 
        e.preventDefault(); 
        cosmetic_get_posts();     
    });

The expanded list is specially located outside the container with filtered posts, so that you can select other values ​​after working out the adjax.
It remains expanded and displays the active value. When the sidebar with it was on the side, it was convenient. According to the layout, it is on top, it would be more convenient for the client if the expanded list folds back.

I tried inserting this parent or find after e.preventDefault() too, something did not help, or I made a mistake in nesting.
Large nesting for a reason - there you need to add individual classes for styles, but here you can display generalized ones for all lists at once. You need to call the .st-accordion container, which wraps the ul li-shki, in which there is not just any one, but this input, on which the change trigger was.

I’m unlikely to post the code on Wednesday, it’s very, very, very, very long. and dynamic, not static. And other moments I think are not involved here.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question