0

I have two buttons, which change the views with ng-show, and I have a filter on the default view. Filter is a dropdown that works with SlideToggle() and it works until I click the other button and go to the second view and when I click bac to the default one, dropdown stops working. I've inspected it in Chrome, nothing happens this is the code for the dropdown:

<div ng-if="filter.entity === 'user'" class="col-md-12 filter-group">
<h5 class="open">Age<span class="caret"></span></h5>
   <div class="filter-group-items filter">
       <div>Age
         <rzslider rz-slider-model="filter.ageMin" rz-slider high="filter.ageMax" rz-slider-options="sliderOptionsAmount">
         </rzslider>
       </div>
   <div>
</div>

This it the js

  $(".open").click(() => {
  $(".filter").slideToggle()
  })
R. Richards
  • 24,603
  • 10
  • 64
  • 64
frontendgirl
  • 57
  • 1
  • 13

2 Answers2

1

The problem is the same like binding events on AJAX loaded content, see How to bind Events on Ajax loaded Content?

jQuery event binding for dynamic content should look like this:

$(document).on("click", ".open", () => { $(".filter").slideToggle(); });

James Wrcsti
  • 220
  • 1
  • 8
1

I think it could be the fact that JQuery is updating the DOM and angular does not know about it. I would try doing all in angular and it would work

tfa
  • 1,643
  • 16
  • 18