Skip to main content
added 90 characters in body
Source Link
Alexander
  • 57
  • 1
  • 11

So if i use the following in functions.php in the root off my child folder it works as supposed:

add_action( 'wp_enqueue_scripts', 'register_my_scripts');
add_action( 'wp_enqueue_scripts', 'checkboxCheckAll');
//register_scripts
function register_my_scripts(){

wp_register_script('checkboxCheckAll', get_stylesheet_directory_uri().'/Lib/dynamic-table/jsScripts/checkboxCheckAll.js');
}

//enqueue_scripts
function enqueue_my_scripts(){
wp_enqueue_script('checkboxCheckAll');
}

now i have a custom page with the following code:

<?php /* Template Name: vagter-flex */ ?>

<?php get_header(); ?>


    <div class="x-main full" role="main">

      <?php while ( have_posts() ) : the_post(); ?>

        <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
          <div class="entry-wrap">

            <?php x_get_view( 'global', '_content', 'the-content' ); ?>
            <?php require('Lib/dynamic-table/functions.php');?>
          </div>
        </article>

      <?php endwhile; ?>

    </div>


<?php get_footer(); ?>

now this page also loads a file called functions.php and if i try to enqueue the script with the same code as above its not working, there is no errors displayed and simply nothing happens?

and just to make it clear yes i am on the custom page when i try to use the script

So if i use the following in functions.php in the root off my child folder it works as supposed:

add_action( 'wp_enqueue_scripts', 'register_my_scripts');
add_action( 'wp_enqueue_scripts', 'checkboxCheckAll');
//register_scripts
function register_my_scripts(){

wp_register_script('checkboxCheckAll', get_stylesheet_directory_uri().'/Lib/dynamic-table/jsScripts/checkboxCheckAll.js');
}

//enqueue_scripts
function enqueue_my_scripts(){
wp_enqueue_script('checkboxCheckAll');
}

now i have a custom page with the following code:

<?php /* Template Name: vagter-flex */ ?>

<?php get_header(); ?>


    <div class="x-main full" role="main">

      <?php while ( have_posts() ) : the_post(); ?>

        <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
          <div class="entry-wrap">

            <?php x_get_view( 'global', '_content', 'the-content' ); ?>
            <?php require('Lib/dynamic-table/functions.php');?>
          </div>
        </article>

      <?php endwhile; ?>

    </div>


<?php get_footer(); ?>

now this page also loads a file called functions.php and if i try to enqueue the script with the same code as above its not working, there is no errors displayed and simply nothing happens?

So if i use the following in functions.php in the root off my child folder it works as supposed:

add_action( 'wp_enqueue_scripts', 'register_my_scripts');
add_action( 'wp_enqueue_scripts', 'checkboxCheckAll');
//register_scripts
function register_my_scripts(){

wp_register_script('checkboxCheckAll', get_stylesheet_directory_uri().'/Lib/dynamic-table/jsScripts/checkboxCheckAll.js');
}

//enqueue_scripts
function enqueue_my_scripts(){
wp_enqueue_script('checkboxCheckAll');
}

now i have a custom page with the following code:

<?php /* Template Name: vagter-flex */ ?>

<?php get_header(); ?>


    <div class="x-main full" role="main">

      <?php while ( have_posts() ) : the_post(); ?>

        <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
          <div class="entry-wrap">

            <?php x_get_view( 'global', '_content', 'the-content' ); ?>
            <?php require('Lib/dynamic-table/functions.php');?>
          </div>
        </article>

      <?php endwhile; ?>

    </div>


<?php get_footer(); ?>

now this page also loads a file called functions.php and if i try to enqueue the script with the same code as above its not working, there is no errors displayed and simply nothing happens?

and just to make it clear yes i am on the custom page when i try to use the script

Source Link
Alexander
  • 57
  • 1
  • 11

wp_enqueue wont work on some files?

So if i use the following in functions.php in the root off my child folder it works as supposed:

add_action( 'wp_enqueue_scripts', 'register_my_scripts');
add_action( 'wp_enqueue_scripts', 'checkboxCheckAll');
//register_scripts
function register_my_scripts(){

wp_register_script('checkboxCheckAll', get_stylesheet_directory_uri().'/Lib/dynamic-table/jsScripts/checkboxCheckAll.js');
}

//enqueue_scripts
function enqueue_my_scripts(){
wp_enqueue_script('checkboxCheckAll');
}

now i have a custom page with the following code:

<?php /* Template Name: vagter-flex */ ?>

<?php get_header(); ?>


    <div class="x-main full" role="main">

      <?php while ( have_posts() ) : the_post(); ?>

        <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
          <div class="entry-wrap">

            <?php x_get_view( 'global', '_content', 'the-content' ); ?>
            <?php require('Lib/dynamic-table/functions.php');?>
          </div>
        </article>

      <?php endwhile; ?>

    </div>


<?php get_footer(); ?>

now this page also loads a file called functions.php and if i try to enqueue the script with the same code as above its not working, there is no errors displayed and simply nothing happens?