Drupal behaviors not attached after Ajax load I'm facing a weird problem on my clean Drupal Installation 
I attached a js library to page with this 

function fs_gal_preprocess_page(&amp;$variables) {
    $variables['#attached']['library'][] = 'fs_gal/fs_gal';
}


This js file I have: 

(function ($, Drupal, drupalSettings) {
  'use strict';
   Drupal.behaviors.GalJs = {
    attach: function (context, settings) {
        alert("Gal");
    }
  };
}) (jQuery, Drupal, drupalSettings);


In my custom theme I created a Ajax call:

$('.button a').on('click', function (e) {
    e.preventDefault()
    $.ajax({
        type: "POST",
        url: "path-to-controller",
        cache: false,
        success: function(htmlText) {
            $('.text-container').html(htmlText);
        }
    });
});


After clicking the button, the text is correctly replaced in the .test-container but the library is not re-attached to the newly changed DOM.
Do someone know a technique to re-attach all behaviors to the content injected after an Ajax call ?

Many thanks for your help
Behaviours are fired after a Drupal AJAX call - a call to jQuery.ajax isn’t the same thing.

Fortunately it’s easy to attach them yourself, just add this in the success callback when you’ve finished manipulating the DOM:

Drupal.attachBehaviors();