DHTMLX Error on dock [ing] an undocked cell - javascript

I am having trouble getting an undocked cell in DHTMLX 4 to dock.
When I click on the provided "dock" button(on the undocked cell) I get the error:
Uncaught TypeError: Cannot read property 'close' of null
I also get this same error when assigning the .dock() function to another button.
onclick: function ()
{
// where to undock to
_this.dhxLayout.dhxWins.attachViewportTo("layout_div");
// init & undock window
var popup_cell = _this.dhxLayout.cells("c");
popup_cell.undock(0,0,800,600);
var popup_window = _this.dhxLayout.dhxWins.window("c");
popup_window.button("minmax1").hide();
popup_window.setText(" ");
// things to do when window is opened
popup_cell.attachEvent("onUnDock", alert("undocked"));
// assigning .dock() to another button, neither work
popup_window.button("park").attachEvent("onClick", function(popup_window){_this.dhxLayout.cells("c").dock();});
// popup_window.button("park").attachEvent("onClick", function(popup_window){popup_cell.dock()});
}
The traceback takes me to c=this.layout.dhxWins.window(this.conf.name);c.close(); so I am guessing that c is somehow undefined? Is there an argument/parameter I am supposed to be passing in the .dock(foo)? The API shows no examples with it.
Any help is greatly appreciated!

I missed out on this: http://forum.dhtmlx.com/viewtopic.php?f=5&t=37052
And followed it to change the offending line of:
c=this.layout.dhxWins.window(this.conf.name);c.close();
(in dhtmlx.js)
to
c=g.dhxWins.window(this.conf.name);c.close();
and the problem is fixed!

Related

FabricJS: Cannot read property of 'e' of undefined

Getting the following error and even though I know what the error means (an object is undefined/null so its property e fails), I'm not sure why it's getting this error. Pretty sure it is related to some FabricJS object and not just plain Javascript. If anyone that knows FabricJS can help me out, that would be great.
fabric.js:8466 Uncaught TypeError: Cannot read property 'e' of undefined
at klass.onMouseDown (fabric.js:8466)
at HubConnection.<anonymous> (chat.js:128)
My code: This function is client side code for receiving a mousedown event from the server (which gets that info from the sending client). It create a new PencilBrush object on the receiving client, and starts it at the same position the sending client presses mousedown. Basically I'm trying to display what the sending client is drawing to receiving client in live time, and this is one of the functions that helps with that.
connection.on("ReceiveMouseDown", function (user, coordinate) { //coordinate is a string
console.log("inside receive mouse down: " + coordinate); //this returns {x: value, y: value}
var coordinateObject = JSON.parse(coordinate);
console.log('coordinateObject is: ' + coordinateObject); //this returns [object object]
brush = new fabric.PencilBrush(canvas);
brush.onMouseDown(coordinateObject); //this is line 128, exception occurs here
//brush.onMouseDown(coordinate); I have also tried this way, but same exception happens
canvas.renderAll();
});
My findings: I think the PencilBrush.onMouseDown() method takes a Pointer (as seen here http://fabricjs.com/docs/fabric.PencilBrush.html ), but the docs aren't very good at explaining what a Pointer object is.
If any one is trying with recent fabric js and facing the same issue, try following. I am using version 4.4.0
var canvas = new fabric.Canvas(document.getElementById('canvasId'));//Primary canvas
var canvas2 = new fabric.Canvas(document.getElementById('canvasId2'));//Drawing programmatically on second canvas
//Getting points from first canvas
const pointer = canvas.getPointer(e);
//Drawing on second convas
let options = {pointer,e:{}};
canvas2.freeDrawingBrush.onMouseDown(initialPointer,options);
I think you are using version 3.3. Try using version 3.2 instead of version 3.3... the source code has been changed a bit to require an extra param.

Ckeditor - replace

I'm currently working wit the CKEditor.
I have a form where user can fill data inside the CKEditor. When the user clicks the save button ajax is called. Inside the ajax call I replace the data with the form data. Before the ajaxFormOnSuccess() method I'm trying to destroy all the instances and replacing them again.
The destroy works properly but when I try to add an instance again i'm getting the error:
Uncaught TypeError: Cannot read property 'unselectable' of null
at c (ckeditor.js:227)
at a. (ckeditor.js:224)
at a.g (ckeditor.js:10)
at a.CKEDITOR.event.CKEDITOR.event.fire (ckeditor.js:11)
at a.CKEDITOR.editor.CKEDITOR.editor.fire (ckeditor.js:13)
at a.fireOnce (ckeditor.js:12)
at a.CKEDITOR.editor.CKEDITOR.editor.fireOnce (ckeditor.js:13)
at Object. (ckeditor.js:177)
at k (ckeditor.js:161)
at Object.load (ckeditor.js:161)
Here is the code for destroying and adding them again.
$('textarea.ckeditor').each(function () {
var txtBoxID = this.attributes.id.nodeValue;
var editor = CKEDITOR.instances[txtBoxID];
if (editor) {
editor.destroy(true);
}
});
CKEDITOR.replace('GeneralData.TypeOfInsuranceGoods', { autoParagraph: false });
Currently just adding a single instance to test it but I'm getting the error(see above).
Does anyone know what I am doing wrong?
Thank you in behave.
Brent

angucomplete-alt:clearInput error Unable to get property 'originalObject'

I'm new to angularjs and am trying to use the angucomplete-alt to allow the user to search for worker names. The search works great, but when I try to clear the input box after the user selects a result the box clears but I get this error message...
TypeError: Unable to get property 'originalObject' of undefined or null reference
at $scope.nameSelected (..Worker.php:498:3)
at callOrAssign (..angucomplete-alt.js:167:11)
at Anonymous function (..angucomplete-alt.js:124:11)
at Scope.prototype.$broadcast (..angular.js:18487:15)
at $scope.deleteRow (..Worker.php:471:6)
at fn (Function code:2:153)
at callback (..angular.js:26994:17)
at Scope.prototype.$eval (..angular.js:18161:9)
at Scope.prototype.$apply (..angular.js:18261:13)
at Anonymous function (..angular.js:26999:17)
Everything seems to work fine, but I hate getting a huge error every time.
this is the box
<angucomplete-alt id="workerName"
placeholder="Name"
pause="100"
minlength="2"
selected-object="nameSelected"
remote-url="Suggest_Name.php?term="
remote-url-data-field=""
title-field="value"
input-class="form-control">
</angucomplete-alt>
and this is the clear command
//clear the autocomplete text box
$scope.$broadcast('angucomplete-alt:clearInput','workerName');
thanks to a user's question I think I've figured it out. It looks like the nameSelected function fires when the autocomplete is cleared. Here's nameSelected..
//autocomplete callback function
$scope.nameSelected = function ($item){
if($item != undefined){ //I just added this
//console.log($item.originalObject);
$scope.worker_new.Emp_Name = $item.originalObject.lastname + ', ' + $item.originalObject.firstname;
$scope.worker_new.PDCWorker_EID = $item.originalObject.UWIdNbr;
$scope.worker_new.PCA_Option = $item.originalObject.pca_option;
}
}
adding the check to see if '$item' is undefined has solved my error problem.

Highcharts nodeName of undefined

When playing around with a chart generated by highcharts, and exporting it to SVG, I get a lot of errors, about 1000 (nodeName of undefined) per 6 seconds
The code responsible is this:
element = wrapper.element,
nodeName = element.nodeName, // <---- Here (Cannot read property 'nodeName' of undefined)
renderer = wrapper.renderer,
skipAttr,
attrSetters = wrapper.attrSetters,
shadows = wrapper.shadows,
hasSetSymbolSize,
ret = wrapper;
The stacktrace (in Chrome 17.0.963)
Uncaught TypeError: Cannot read property 'nodeName' of undefined
SVGElement.attr highcharts.src.js:2008
init.Effect.HighchartsTransition.Class.create.update prototype-adapter.src.js:86
(anonymous function) effects.js:1
Effect.Base.Class.create.loop effects.js:1
Effect.ScopedQueue.Class.create.loop effects.js:1
b prototype.js:1
The fiddle to re-create : here, to reproduce click the series on/off and then click on the My Download link, switch on/off again and click on the My Download link again.
My question is as follows, is this my code, or a bug in highcharts; and how can I fix it?
Got the answer I was looking for; It was a bug in highcharts, fixed here
I am not really familiar with Prototype framework, but I did some tests and look at this code:
function getGraphSVG(options) {
var svg;
if (window.charts) {
window.charts.each(function(pair) {
svg = pair.value.getSVG(options);
throw $break;
});
}
return svg;
}
Somehow this each method returns 2 objects, one being undefined. So do the simple check:
if (pair.value)
svg = pair.value.getSVG(options);
or in one line
pair.value && ( svg = pair.value.getSVG(options) );
and it should work.

Extending DOMWindow object

I'm a total JavaScript/jQuery n00b, so please forgive me in advance.
Imagine there's a webpage (W1) which displays a list of items (I1, I2, ...). Now there's a second webpage W2 which displays W1 in a FancyBox'ed iframe (<a class="iframe" href="addressof(W1)">Pick items</a>).
Each item inside a W1 has a JavaScript handler attached to its click event, which does this:
function SetOpenerClient(id, name,isHoldings)
{
var _hfBackPath = document.getElementById('ctl00_main_hfBackPath');
var url = _hfBackPath.value;
window.navigate(url +"?id="+id+"&name="+name+"&isHol="+isHoldings);
}
The usual way this whole mess is used is by window.open()ing a window and providing a "backpath":
window.open(addressof(W1) + "?backpath=" + addressOfHandlerThisWebSite,
"selectClient",
"status=no,toolbar=no,menubar=no,location=no,scrollbars=yes")
Now here's whay my investigations show. Whenever a user click on an item inside of W1, it niavigates back to backpath (_hfBackPath from SetOpenerClient()), which happens to be a specially crafted page which grabs id querystring parameter, stuffs it inside a Session and does all kinds of other stuff.
When W1 gets opened inside an iframe, Chrome complains:
Uncaught TypeError: Object [object DOMWindow] has no method 'navigate'
Here's whay I want (by the way, there's $50 bill glued under your chair) and I really hope this is possible. I want to "redefine" window.navigate method to so that I could handle item selection manually. Is this possible? My naive attempts of setting
DOMWindow.navigate = function () { alert("window.navigate"); };
apparently don't do anything.

Categories