CKEditor 4.7x - Uncaught SyntaxError: Invalid shorthand property initializer - javascript

I am trying to get the imageuploader working with CKeditor and I get the following error:
Uncaught SyntaxError: Invalid shorthand property initializer load_ckeditor.js
Here is the contents of_ckeditor.js
CKEDITOR.plugins.addExternal(
'imageuploader',
'/themes/blog/imageuploader/',
'plugin.js'
);
CKEDITOR.replace( 'editor1',{
extraPlugins = 'imageuploader'
});
The error line number refers to this:
extraPlugins = 'imageuploader'
I have copied the code exactly per the example here: https://cdn.ckeditor.com/
When I remove, extraPlugins = 'imageuploader', the CKEditor loads properly but it is missing the plugin.

There's an error in your syntax, CKEDITOR.replace takes an object so it requires a colon not an equals. The correct implementation should be:
CKEDITOR.replace( 'editor1',{
extraPlugins: 'imageuploader'
});

Related

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

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();

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

Passing variable to function in javascript and jQuery

quick question,why this don`t work and how to fix it
$("#Button").click(function(){
count++;
var b=new Button(count);
b.render();
$("#div"+ count).dblclick(function(){
var diva=this;
$(this).append("<span id='colorchange'><input type='color' id='color' onchange='func("+diva+")' name='favcolor'></span>");
});
});
function func(diva){
alert(diva);
}
i`m getting error Uncaught SyntaxError: Unexpected identifier
You can add jquery library "http://code.jquery.com/jquery-1.9.1.js",
and Button is not recognized unless you defined it anywhere...
You can get help from "http://sideroad.secret.jp/plugins/jQueryRender/"

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");

How do I resolve an AutoComplete error when using CodeMirror?

I want to use the AutoComplete of CodeMirror, but I'm getting the error:
Uncaught TypeError: Cannot read property 'javascript' of undefined
CodeMirror.commands.autocomplete = function(cm) {
CodeMirror.showHint(cm, CodeMirror.hint.javascript); // Error Here
}
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
extraKeys: {"Ctrl-Space": "autocomplete"}
});
In order to use autocomplete capabilities, you must insure to include the appropriate scripts, i.e. show-hint.js, show-hint.css and javascript-hint.js (which seems like the one causing the fuss here).
Take a look at the autocomplete demo's source code for a reference.

Categories