WordPress Edit Page editor unresponsive - jQuery Error?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















When I go to edit my page I cannot open screen options or switch between visual and Text mode in the editor.



I've tried adding



define('CONCATENATE_SCRIPTS', false);
define('SCRIPT_DEBUG', true);


to wp config but it hasn't helped



My jQuery load script is this



function loadJquery()
{
if ($hook != 'post-new.php' || $hook != 'post.php' ) {
wp_register_script('siteJs',get_template_directory_uri() .
'/js/site.js',array('jquery'),'1.4.1');
wp_enqueue_script('siteJs'); // Enqueue it!
}
}


I get this error:




Uncaught TypeError: Cannot read property 'addEventListener' of null




Referring to this:



(function() {
var burger = document.querySelector('.navbar-burger');
var menu = document.querySelector('.navbar-menu');
burger.addEventListener('click', function() {
burger.classList.toggle('is-active');
menu.classList.toggle('is-active');
});


And as the page sits there it also brings up this error:




Uncaught TypeError: Cannot read property 'hasClass' of undefined

at HTMLDocument. (wp-auth-check.js:101)











share|improve this question




















  • 1





    Does site.js need to load in WP admin? If not, try enqueueing the script with add_action( 'wp_enqueue_scripts', 'loadJquery' ); instead of wherever loadJquery is currently loading. (You'd need to remove the if statement checking the $hook value for this...)

    – dafoxuk
    Jan 3 at 13:51


















0















When I go to edit my page I cannot open screen options or switch between visual and Text mode in the editor.



I've tried adding



define('CONCATENATE_SCRIPTS', false);
define('SCRIPT_DEBUG', true);


to wp config but it hasn't helped



My jQuery load script is this



function loadJquery()
{
if ($hook != 'post-new.php' || $hook != 'post.php' ) {
wp_register_script('siteJs',get_template_directory_uri() .
'/js/site.js',array('jquery'),'1.4.1');
wp_enqueue_script('siteJs'); // Enqueue it!
}
}


I get this error:




Uncaught TypeError: Cannot read property 'addEventListener' of null




Referring to this:



(function() {
var burger = document.querySelector('.navbar-burger');
var menu = document.querySelector('.navbar-menu');
burger.addEventListener('click', function() {
burger.classList.toggle('is-active');
menu.classList.toggle('is-active');
});


And as the page sits there it also brings up this error:




Uncaught TypeError: Cannot read property 'hasClass' of undefined

at HTMLDocument. (wp-auth-check.js:101)











share|improve this question




















  • 1





    Does site.js need to load in WP admin? If not, try enqueueing the script with add_action( 'wp_enqueue_scripts', 'loadJquery' ); instead of wherever loadJquery is currently loading. (You'd need to remove the if statement checking the $hook value for this...)

    – dafoxuk
    Jan 3 at 13:51














0












0








0








When I go to edit my page I cannot open screen options or switch between visual and Text mode in the editor.



I've tried adding



define('CONCATENATE_SCRIPTS', false);
define('SCRIPT_DEBUG', true);


to wp config but it hasn't helped



My jQuery load script is this



function loadJquery()
{
if ($hook != 'post-new.php' || $hook != 'post.php' ) {
wp_register_script('siteJs',get_template_directory_uri() .
'/js/site.js',array('jquery'),'1.4.1');
wp_enqueue_script('siteJs'); // Enqueue it!
}
}


I get this error:




Uncaught TypeError: Cannot read property 'addEventListener' of null




Referring to this:



(function() {
var burger = document.querySelector('.navbar-burger');
var menu = document.querySelector('.navbar-menu');
burger.addEventListener('click', function() {
burger.classList.toggle('is-active');
menu.classList.toggle('is-active');
});


And as the page sits there it also brings up this error:




Uncaught TypeError: Cannot read property 'hasClass' of undefined

at HTMLDocument. (wp-auth-check.js:101)











share|improve this question
















When I go to edit my page I cannot open screen options or switch between visual and Text mode in the editor.



I've tried adding



define('CONCATENATE_SCRIPTS', false);
define('SCRIPT_DEBUG', true);


to wp config but it hasn't helped



My jQuery load script is this



function loadJquery()
{
if ($hook != 'post-new.php' || $hook != 'post.php' ) {
wp_register_script('siteJs',get_template_directory_uri() .
'/js/site.js',array('jquery'),'1.4.1');
wp_enqueue_script('siteJs'); // Enqueue it!
}
}


I get this error:




Uncaught TypeError: Cannot read property 'addEventListener' of null




Referring to this:



(function() {
var burger = document.querySelector('.navbar-burger');
var menu = document.querySelector('.navbar-menu');
burger.addEventListener('click', function() {
burger.classList.toggle('is-active');
menu.classList.toggle('is-active');
});


And as the page sits there it also brings up this error:




Uncaught TypeError: Cannot read property 'hasClass' of undefined

at HTMLDocument. (wp-auth-check.js:101)








php jquery wordpress editor admin






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 8 at 20:19









marc_s

585k13011261272




585k13011261272










asked Jan 3 at 13:43









Chris CullenChris Cullen

138




138








  • 1





    Does site.js need to load in WP admin? If not, try enqueueing the script with add_action( 'wp_enqueue_scripts', 'loadJquery' ); instead of wherever loadJquery is currently loading. (You'd need to remove the if statement checking the $hook value for this...)

    – dafoxuk
    Jan 3 at 13:51














  • 1





    Does site.js need to load in WP admin? If not, try enqueueing the script with add_action( 'wp_enqueue_scripts', 'loadJquery' ); instead of wherever loadJquery is currently loading. (You'd need to remove the if statement checking the $hook value for this...)

    – dafoxuk
    Jan 3 at 13:51








1




1





Does site.js need to load in WP admin? If not, try enqueueing the script with add_action( 'wp_enqueue_scripts', 'loadJquery' ); instead of wherever loadJquery is currently loading. (You'd need to remove the if statement checking the $hook value for this...)

– dafoxuk
Jan 3 at 13:51





Does site.js need to load in WP admin? If not, try enqueueing the script with add_action( 'wp_enqueue_scripts', 'loadJquery' ); instead of wherever loadJquery is currently loading. (You'd need to remove the if statement checking the $hook value for this...)

– dafoxuk
Jan 3 at 13:51












2 Answers
2






active

oldest

votes


















1














The error Uncaught TypeError: Cannot read property 'addEventListener' of null is indicating that burger is undefined. While it may be worth reviewing whether site.js should be running on the WP Admin (where .navbar-burger doesn't even exist), the direct fix is to check whether burger is found before adding the event listener.



This would look like:



(function() {
var burger = document.querySelector('.navbar-burger');
var menu = document.querySelector('.navbar-menu');
if (burger != null && menu != null){
burger.addEventListener('click', function() {
burger.classList.toggle('is-active');
menu.classList.toggle('is-active');
});
}
})();





share|improve this answer
























  • It was simply me loading Jquery with wp_print_scripts instead of enqueue Thanks!

    – Chris Cullen
    Jan 3 at 14:39





















0














I was using



wp_print_scripts


to load Jquery
when as dafoxuk said I should be using



wp_enqueue_scripts()


godbless you :)






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54023489%2fwordpress-edit-page-editor-unresponsive-jquery-error%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    The error Uncaught TypeError: Cannot read property 'addEventListener' of null is indicating that burger is undefined. While it may be worth reviewing whether site.js should be running on the WP Admin (where .navbar-burger doesn't even exist), the direct fix is to check whether burger is found before adding the event listener.



    This would look like:



    (function() {
    var burger = document.querySelector('.navbar-burger');
    var menu = document.querySelector('.navbar-menu');
    if (burger != null && menu != null){
    burger.addEventListener('click', function() {
    burger.classList.toggle('is-active');
    menu.classList.toggle('is-active');
    });
    }
    })();





    share|improve this answer
























    • It was simply me loading Jquery with wp_print_scripts instead of enqueue Thanks!

      – Chris Cullen
      Jan 3 at 14:39


















    1














    The error Uncaught TypeError: Cannot read property 'addEventListener' of null is indicating that burger is undefined. While it may be worth reviewing whether site.js should be running on the WP Admin (where .navbar-burger doesn't even exist), the direct fix is to check whether burger is found before adding the event listener.



    This would look like:



    (function() {
    var burger = document.querySelector('.navbar-burger');
    var menu = document.querySelector('.navbar-menu');
    if (burger != null && menu != null){
    burger.addEventListener('click', function() {
    burger.classList.toggle('is-active');
    menu.classList.toggle('is-active');
    });
    }
    })();





    share|improve this answer
























    • It was simply me loading Jquery with wp_print_scripts instead of enqueue Thanks!

      – Chris Cullen
      Jan 3 at 14:39
















    1












    1








    1







    The error Uncaught TypeError: Cannot read property 'addEventListener' of null is indicating that burger is undefined. While it may be worth reviewing whether site.js should be running on the WP Admin (where .navbar-burger doesn't even exist), the direct fix is to check whether burger is found before adding the event listener.



    This would look like:



    (function() {
    var burger = document.querySelector('.navbar-burger');
    var menu = document.querySelector('.navbar-menu');
    if (burger != null && menu != null){
    burger.addEventListener('click', function() {
    burger.classList.toggle('is-active');
    menu.classList.toggle('is-active');
    });
    }
    })();





    share|improve this answer













    The error Uncaught TypeError: Cannot read property 'addEventListener' of null is indicating that burger is undefined. While it may be worth reviewing whether site.js should be running on the WP Admin (where .navbar-burger doesn't even exist), the direct fix is to check whether burger is found before adding the event listener.



    This would look like:



    (function() {
    var burger = document.querySelector('.navbar-burger');
    var menu = document.querySelector('.navbar-menu');
    if (burger != null && menu != null){
    burger.addEventListener('click', function() {
    burger.classList.toggle('is-active');
    menu.classList.toggle('is-active');
    });
    }
    })();






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 3 at 14:04









    dafoxukdafoxuk

    20927




    20927













    • It was simply me loading Jquery with wp_print_scripts instead of enqueue Thanks!

      – Chris Cullen
      Jan 3 at 14:39





















    • It was simply me loading Jquery with wp_print_scripts instead of enqueue Thanks!

      – Chris Cullen
      Jan 3 at 14:39



















    It was simply me loading Jquery with wp_print_scripts instead of enqueue Thanks!

    – Chris Cullen
    Jan 3 at 14:39







    It was simply me loading Jquery with wp_print_scripts instead of enqueue Thanks!

    – Chris Cullen
    Jan 3 at 14:39















    0














    I was using



    wp_print_scripts


    to load Jquery
    when as dafoxuk said I should be using



    wp_enqueue_scripts()


    godbless you :)






    share|improve this answer




























      0














      I was using



      wp_print_scripts


      to load Jquery
      when as dafoxuk said I should be using



      wp_enqueue_scripts()


      godbless you :)






      share|improve this answer


























        0












        0








        0







        I was using



        wp_print_scripts


        to load Jquery
        when as dafoxuk said I should be using



        wp_enqueue_scripts()


        godbless you :)






        share|improve this answer













        I was using



        wp_print_scripts


        to load Jquery
        when as dafoxuk said I should be using



        wp_enqueue_scripts()


        godbless you :)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 3 at 14:37









        Chris CullenChris Cullen

        138




        138






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54023489%2fwordpress-edit-page-editor-unresponsive-jquery-error%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            SQL update select statement

            WPF add header to Image with URL pettitions [duplicate]