Here is how I am enqueueing the script (this is inside a class):
add_action( 'admin_enqueue_scripts', array( $this, 'add_admin_scripts'), true);
public function add_admin_scripts(){
$parentBase = get_current_screen();
if($parentBase->id == 'toplevel_page_calc-settings'){
wp_enqueue_style( 'l7w-admin-js', $this->pluginUrl . 'assets/js/admin.min.js');
}
}
Here is the simple script:
$(document).ready(function(){
alert("Works");
console.log('Works');
});
The js is showing and is loaded on the settings page but the alert() and the console.log() are not executed.
Why am I not seeing the alert or the console.log()?
$, WordPress' jQuery object reference isjQuery, not$.Resource interpreted as Stylesheet but transferred with MIME type application/javascriptwp_enqueue_styleinstead ofwp_enqueue_script.