Why the list item dont stay active when is clicked?

Why the list item dont stay active when is clicked?

I have a menu with some categories:

  1.         <ul class="Categories__Menu">
  2.             @foreach($categories->take(6) as $category)
  3.                 <li class="active">
  4.                     <a href="#" name="category" id="{{$category->id}}" href="#">{{$category->name}}</a>
  5.                 </li>
  6.             @endforeach
  7.             <li><a  data-toggle="modal" id="showCategories" data-target=".bd-example-modal-lg" href="">More</a></li>
  8.         </ul>

If the user clicks in More it opens a modal with more categories, the modal have this content:

  1.     <div class="modal fade bd-example-modal-lg" id="categoriesModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
  2.         <div class="modal-dialog modal-lg">
  3.                 <div class="modal-body">
  4.                     <div class="container">
  5.                         <div class="row">
  6.                             <ul class="modal-list row">
  7.                                 <li class="col-lg-4 col-md-6 col-sm-12">
  8.                                     <a class="">All Categories</a>
  9.                                 </li>
  10.                                 @foreach($categories as $category)
  11.                                     <li class="col-lg-4 col-md-6 col-sm-12">
  12.                                         <img src="{{ $category->image }}"/>
  13.                                         <a name="category" id="{{$category->id}}">{{$category->name}}</a>
  14.                                     </li>
  15.                                 @endforeach
  16.                             </ul>
  17.                         </div>
  18.                     </div>
  19.                 </div>
  20.         </div>
  21.     </div>

I have some jquery to do an ajax request to get the conferences that belong to the clicked category. This is working fine.

But I want that the clicked category becomes active in the menu "Categories__Menu". But its not working, the clicked category don't stays active. 

This fiddle " http://jsfiddle.net/e7gjv5ct/6/" demonstrates the issue. The item doesn't stays with the class active when is clicked. And also the item "More" changes the text from "More" to the clicked item text, but the item "More" should only change the text to the clicked category text when a category in the modal is clicked, that is, it should not change when a category in the menu "Categories__Menu" is clicked. 

Do you know where is the issue?

  1.     $("a[name='category']").on('click', function(){
  2.         $('#showCategories').html($(this).text()+' <i class="fa fa-caret-down" aria-hidden="true"></i>');
  3.         $('#categoriesModal').modal('hide');
  4.         $('#showCategories').addClass('active');
  5.     
  6.         var category_id = $(this).attr("id");
  7.         //alert(category_id);
  8.     
  9.         $('.Categories__Menu li').removeClass('active');
  10.         $(this).parent('li').addClass('active');
  11.     
  12.         $.ajax({
  13.     
  14.             url: '{{ route('category.conferences',null) }}/' + category_id,
  15.             type: 'GET',
  16.             success:function(result){
  17.                 $('#conferences').empty();
  18.                 var newConferences='';
  19.                 var placeholder = "{{route('conferences.show', ['id' => '1', 'slug' => 'demo-slug'])}}";
  20.                 $.each(result, function(index, conference) {
  21.                     var url = placeholder.replace(1, conference.id).replace('demo-slug', conference.slug);
  22.     
  23.                     newConferences += '<div class="col-12 col-sm-6 col-lg-4 col-xl-3 mb-4">\n' +
  24.     '                        <div class="card box-shaddow">\n' +
  25.     '                            <img class="card-img-top" src='+ conference.image +' alt="Card image cap">\n' +
  26.     '                            <div class="card-body">\n' +
  27.     '                                <h5 class="card-title">'+conference.name+'</h5>\n' +
  28.     '                            </div>\n' +
  29.     '                    </div></div>';
  30.                 });
  31.                 $('#conferences').html(newConferneces);
  32.             },
  33.             error: function(error) {
  34.                 console.log(error.status)
  35.             }
  36.         });
  37.     });