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;
}
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
add a comment |
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
1
Does site.js need to load in WP admin? If not, try enqueueing the script withadd_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
add a comment |
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
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
php jquery wordpress editor admin
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 withadd_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
add a comment |
1
Does site.js need to load in WP admin? If not, try enqueueing the script withadd_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
add a comment |
2 Answers
2
active
oldest
votes
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');
});
}
})();
It was simply me loading Jquery with wp_print_scripts instead of enqueue Thanks!
– Chris Cullen
Jan 3 at 14:39
add a comment |
I was using
wp_print_scripts
to load Jquery
when as dafoxuk said I should be using
wp_enqueue_scripts()
godbless you :)
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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');
});
}
})();
It was simply me loading Jquery with wp_print_scripts instead of enqueue Thanks!
– Chris Cullen
Jan 3 at 14:39
add a comment |
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');
});
}
})();
It was simply me loading Jquery with wp_print_scripts instead of enqueue Thanks!
– Chris Cullen
Jan 3 at 14:39
add a comment |
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');
});
}
})();
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');
});
}
})();
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
add a comment |
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
add a comment |
I was using
wp_print_scripts
to load Jquery
when as dafoxuk said I should be using
wp_enqueue_scripts()
godbless you :)
add a comment |
I was using
wp_print_scripts
to load Jquery
when as dafoxuk said I should be using
wp_enqueue_scripts()
godbless you :)
add a comment |
I was using
wp_print_scripts
to load Jquery
when as dafoxuk said I should be using
wp_enqueue_scripts()
godbless you :)
I was using
wp_print_scripts
to load Jquery
when as dafoxuk said I should be using
wp_enqueue_scripts()
godbless you :)
answered Jan 3 at 14:37
Chris CullenChris Cullen
138
138
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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