How to fix my ReferenceError - javascript

I've got a WordPress website I've been working on for a project of mine, the website is not nearly finished, On the website I have a button "Create A Clan" Which uses Visual composer (A plugin) I've reached out to WP Support with no aid, When I click on the "Create A Clan" Button, The visual composer just loads, and loads. I hit "F12" To try to see what is going on, and I have this error in the panel.
"Uncaught TypeError: undefined is not a function
this.activities_list[i].call(window);
Uncaught ReferenceError: i is not defined(anonymous function) # VM922:1InjectedScript._evaluateOn # VM921:883InjectedScript._evaluateAndWrap # VM921:816InjectedScript.evaluate # VM921:682.
I have no idea what the above means. It tells me that the error is inside of my "vc_Page_Editable.js" folder, within my theme. On line 292.
window.vc_google_fonts();
this.collectScriptsData();
this.loadInlineScripts();
this.loadInlineScriptsBody();
for(var i in this.activities_list) {
this.activities_list[i].call(window);
}
I can add the ENTIRE files contents if needed.

It looks like there is an issue with the list and one of the elements or properties in the list is undefined, so I would say safest bet is to check if that's the case and skip to the next element.
for(var i in this.activities_list) {
if(!i || !this.activities_list[i])
continue;
this.activities_list[i].call(window);
}

Related

Error can't redefine non-configurable property "userAgent"

Lately we have been getting a lot of javascript errors "can't redefine non-configurable property "userAgent"".
We don't attempt to redefine userAgent in our code. We barely even reference userAgent. The only places would be in code like the following:
var browser_msie = (navigator.userAgent.match(/msie/i) || navigator.userAgent.match(/trident/i)) ? true : false;
I am wondering if this error is rather coming from some bad browser behavior. It only started showing up recently.
Last evening we got over 20,000 of such error messages, and all from the same member of our service.
EDIT
The error information is as follows:
Error Message:
Message: TypeError: can't redefine non-configurable property "userAgent"
URL: https://www.rephunter.net/member-home.php
Line:1
Column:130
Stack:#https://www.rephunter.net/member-home.php:1:130
Error Traceback:
#0 Called backtrace in file /var/www/rephunter/www/webroot/include/error-handler-inc.php as line #68
#1 Called error_handler in file as line #
#2 Called trigger_error in file /var/www/rephunter/www/webroot/ajax/javascript-error.php as line #14
Unfortunately this offers no help, as line 1 of the page is just <!DOCTYPE html>. I don't see how to get to that part of the code. Of course if that were possible it might be easy to see the cause of the issue.
I recall in the past the Dev Tools might have given a "spiders view" of the page, but now I only see the DOM on the Elements tab, and Sources. Both of these are formatted and their is no way to see what "line 1 char 130" means.

"Warning: Failed propType: Required prop 'fields' was not specified in 'ReduxForm(MyForm)'"

I've just added Redux to my React app and I thought it was working but now I keep getting two errors in my console.
This:
Warning: Failed propType: Required prop 'fields' was not specified in
'ReduxForm(MyForm)'. Check the render method of
'Connect(ReduxForm(MyForm))'.
and this:
Uncaught TypeError: Cannot read property 'reduce' of undefined
The second refers to this (line 2):
var getValues = function getValues(fields, state) {
return fields.reduce(function (accumulator, field) {
getValue(field, state, accumulator);
return accumulator;
}, {});
};
Upadte/Answer:
Make sure redux-form is version 6 or higher
Teach a man to fish!
You have not really given enough codes to go on.
If fields are unexpectedly undefined then you should step through with chrome debugger or console.log everywhere. These are highly underrated methods!
In the browser hit the F12 key.
Select the Scripts , or Sources , tab in the developer tools.
Hit control+p and enter in the path to the file you are looking for.
(Or located little folder icon in the top level to find your file.)
Add a breakpoint by clicking on the line number on the left (adds a
little blue marker)
Execute your JavaScript.
Your code will run until it stops at the breakpoint and you can step forward from there. If you need to check every line then add breakpoints on all lines before stepping through. You can right click variables to add to watch list.
Keep going until you find a faulty logic, undefined/null, or bug occurs. Note that you can console.log() at any time from the console while the code is paused on a breakpoint and it will log correctly for variables in scope.

Leaflet: Uncaught TypeError: map._getNewTopLeftPoint is not a function

I am trying to follow the JSFiddle example on the link :
http://jsfiddle.net/BeniBoy/aeas62mh/1/
But I keep getting on error :
Uncaught TypeError: map._getNewTopLeftPoint is not a function
when I hover the sidebar or click onto the marker.
I am using pug and loading my script as
script(src='https://unpkg.com/leaflet#1.0.1/dist/leaflet.js')
on the header file.
This method was available until 0.7: https://github.com/Leaflet/Leaflet/blob/0.7/src/map/Map.js#L740
It has been removed in 1.0 (which is the version you are using).
Note that, because it starts with an underscore, it was considered as private and should not have been used in the first place.

Receiving Type Error Cannot Read 'length' ionic.bundle.js

I am receiving Uncaught TypeError: Cannot read property 'length' of undefined error on the load of a certain page of my ionic app.
Because this error points to a file in the core, I am clueless as to how to debug this. I have performed breakpoints throughout the controller file and I am unable to pin it down.
The error comes up after the full page has loaded.
Hopefully this picture paints a 1000 words.
EDIT
I have now tracked this issue to this piece of code.
$ionicModal.fromTemplateUrl('templates/exercise-modal.html', {
scope: $scope
}).then(function (addExerciseModal) {
$scope.addExerciseModal = addExerciseModal;
});
// Triggered in the exercise modal to close it
$scope.closeAddExerciseModal = function() {
$scope.addExerciseModal.hide();
};
// Open the exercise modal
$scope.OpenAddExerciseModal = function() {
$ionicSlideBoxDelegate.slide(0);
$scope.addExerciseModal.show();
};
However I use this elsewhere in my app and it functions just fine..?
Clearly, slides is undefined at the time that line is executing. Look backwards through the source code - a few lines above that you should see something that lets you know what slides is expected to be (if you don't already know).
Then look at how slides is being created/provided, and follow it back to your own code.

Safari Extension safari.application error

I'm making an extension for safari I created a context item with command = showNote
In debugger I get the follwing error TypeError: Result of expression 'safari.application' [undefined] is not an object on line 8(the last line)
are there any things you need to include or call before this works?
main.js
function showNote(event){
if(event.command == "showNote"){
addElement = document.createElement('<div id="safExtNote"><textarea id="safExtNoteText"></textarea><button id="safExtSave">Save</safExtNote></div>');
document.body.appendChild(addElement)
alert("im online");
}
}
safari.application.addEventListener("command", showNote, false);
Just ran into this problem myself trying to create a toolbar command. Turns out I was putting the JS in the wrong place. I added it to the "Injected Extension Content" as a start script. Needed to create an HTML page that included the JS and set that as the Global Page File.
Switch that around and you should be set, assuming it's the same problem I just ran into.

Categories

Resources