Customizer doesn’t recognise sidebar

I found out what the problem was.

I were using jQuery in the wrong way, which made the customizer fail.

This is how you should enqueue a script with jQuery:

function my_theme_scripts() {
    wp_enqueue_script( 'my-great-script', get_template_directory_uri() . '/js/my-great-script.js', array( 'jquery' ), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'my_theme_scripts' );

See more on this page.