Mapbox-Gl-Draw: Cannot set property 'modes' of undefined - javascript

I am trying to initialize a MapboxDraw object with the following JS code:
var graphicsController = MapboxDraw(); // Initialize the graphics controller
I am importing mapbox-gl-draw w/ the following CDN:
<script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-draw/v1.0.9/mapbox-gl-draw.js'></script>
However I get the following error message:
Uncaught TypeError: Cannot set property 'modes' of undefined
(mapbox-gl-draw.js:1)
What does this mean? Is it some bug of mapbox-gl-draw that I can just ignore or do I need to do anything to fix it?

MapboxDraw is a constructor, so you need to initialize it with new keyword:
var graphicsController = new MapboxDraw();

Related

Laravel Uncaught Type Error (Cannot set property elements of #<HTMLFormElement> which has only a getter)

function makeSerializable(elem) {
return $(elem).prop('elements', $('*', elem).addBack().get());
}
---------------------------------------------------
function newPost(){
var form_name = '#form-new-post';
$(form_name + ' .loading-post').show();
var data = new FormData();
data.append('data', JSON.stringify(makeSerializable(form_name).serializeJSON()));
var file_inputs = document.querySelectorAll('.image-input');
$(file_inputs).each(function(index, input) {
data.append('image', input.files[0]);
});
Wondering if anybody can help with this head scratcher?? The function is trying to submit a new post (obviously) I'm really new to this and trying to understand why this call is returning an error and a function not functioning! 2 different javascript files calling/using the function. I cant understand the returning error "Uncaught TypeError: Cannot set property elements of # which has only a getter" any help??
Resolved! Was the simplest of problems. A clash of jQuery files. Just had to remove the old ones still being called.

how to get/set TestStep's property value using javascript in soapUI?

i have tried using Groovy script.
the following code is to set property value using roovy script:
testRunner.testCase.testSuite.testCases[testCaseName].testSteps[testStepName].setPropertyValue("request",object);
"request" is a property of testStep.
object is a some value.
when i try above code in javascript but i got following error:
org.mozilla.javascript.ecmaerror: TypeErro: org.mozilla.javascript.ecmaerror Cannot read property "testSteps" from undefined.
So please tell me how to use in using javascript?
hurra, i got solution. Please see following code:
var project = testRunner.getTestCase().getTestSuite().getProject();
var testSuite = project.getTestSuiteByName("TestSuite");
var testCasesItr=testSuite.getTestCaseList().iterator();
while(testCasesItr.hasNext())
{
var testStepsItr = testCasesItr.getTestStepList().iterator();
while(testStepsItr.hasNext()){
var testStep = testStepsItr.next();
log.info(testStep.getPropertyValue("response"));
// here you can set property
// testStep.setPropertyValue("request","someValue");
}
}
above code will run for all the testcases.

Unable to get property 'validate' of undefined or null reference

I have attached a validator to the container and got a reference by doing below:
var validator = $("#sectionContainer").kendoValidator().data("kendoValidator");
When I run the code below I get an error saying " JavaScript runtime error: Unable to get property 'validate' of undefined or null reference".
if (validator.validate()) {
//do my logic to save form
}
});
What am I doing wrong here ? Am I missing something?
Using jquery version jquery-1.10.2.js and jquery-ui-1.10.3.custom.min.js

js Model Animation Using three.js r68

As stated in the title, I cannot get animation to work. I'm pretty sure I'm missing something in my code because it works here, but not where I'm testing.
I create the animation object in playerCharacter.js with
this.init = function(){
for (var k in this.mesh.material.materials) {this.mesh.material.materials[k].skinning = true;}
this.animation = new THREE.Animation(this.mesh, this.mesh.geometry.animations[0].name);
this.animation.play();
}
In the update function I use:
this.animation.update(0.017);
And when I look at the console log I get:
Uncaught TypeError: Cannot read property 'length' of undefined
So it seems that in THREE.AnimationHandler, data.hierarchy is undefined, so I'm guessing that if I can somehow make it defined, the problem will be fixed. Except I don't know how, or even why it is not defined. Any help?
You are passing only the animation's name, not the whole data object. Use this instead:
this.animation = new THREE.Animation(this.mesh, this.mesh.geometry.animations[0]);

console error when using jquery - Uncaught TypeError: Object #<HTMLElement> has no method

I'm trying to add a class or a css style using the following js but getting a console error
var i = 0;
$(".question")[i].addClass("show");
get the following console log error: Uncaught TypeError: Object # has no method 'addClass'
or / and
$(".question")[i].css("display", "block");
get the following console log error: Uncaught TypeError: Object # has no method 'css'
used info from http://api.jquery.com/get/
EDIT
Still doesn't working if get rid of the variable i, and use numbers 0 or 1
When you access an item from a collection with a subscript like [i], you're actually unwrapping it from the jQuery object, and accessing a raw DOM node, which doesn't have methods like addClass and css.
Use .eq() instead:
var i = 0;
$(".question").eq(i).addClass("show");
$(".question").eq(i).css("display", "block");

Categories