Unable to add content to Textarea editor on Redactor 2. "Uncaught TypeError: Cannot read property 'code' of undefined" - wysiwyg

I have Redactor II (version 1.2.5) which I used to edit content on a database. When the page is loaded I load the content that needs to be edited, and I use the following code to add the content in to the Redactor editor:
$('#eg_description').redactor('code.set', 'My text goes here');
However, when I load the page I get this error:
Uncaught TypeError: Cannot read property 'code' of undefined
I've also tried this:
$('#eg_description').redactor('this.code.set', 'My text goes here');
Which gives the following similar error:
Uncaught TypeError: Cannot read property 'this' of undefined
Not entirely sure why it isn't working, so any help would be appreciated!

Please make sure you first enable Redactor on the same element, i.e. you call
$('#eg_description').redactor(); //you can provide options object here

Related

CheckBox in table

This question is regarding aem 6.3
I have an assignment that requires me to use a checkbox in the table. But I notice that when I do that, I am unable to create a new row through the workflow. May I know is there a workaround over it?
In my console logs, I am getting this error
TypeError: Cannot read property 'id' of undefined at child.handleAccessibility...
Am I suppose to create an id first? If so how do I do that?
Thanks
Norman
It appears to be that aem currently has a bug where the title of the checkbox cannot be hidden if not it will face the aforementioned error. So the solution is not hide the title but let it be blank.
This is more of an issue of that the id cannot be recognised, instead of unable to create a new row through the workflow, that resulted in the latter issue.

Material-UI: issues with dropdown (Select control) inside a Dialog

Just wondering if anyone has seen issues using a dropdown list (Select control) inside a Dialog control. When I change the selection in the dropdown list I get an error:
Uncaught TypeError: Cannot read property 'removeAttribute' of null
at ariaHidden (manageAriaHidden.js:28)
at ModalManager.remove (ModalManager.js:188)
at Modal._this.handleClose (Modal.js:145)
at Modal.componentDidUpdate (Modal.js:221)
at commitLifeCycles (react-dom.development.js:14693)
at commitAllLifeCycles (react-dom.development.js:15905)
at HTMLUnknownElement.callCallback (react-dom.development.js:145)
at Object.invokeGuardedCallbackDev (react-dom.development.js:195)
at invokeGuardedCallback (react-dom.development.js:248)
at commitRoot (react-dom.development.js:16075)
at completeRoot (react-dom.development.js:17463)
at performWorkOnRoot (react-dom.development.js:17391)
at performWork (react-dom.development.js:17295)
at performSyncWork (react-dom.development.js:17267)
at interactiveUpdates$1 (react-dom.development.js:17558)
at interactiveUpdates (react-dom.development.js:2208)
at dispatchInteractiveEvent (react-dom.development.js:4913)
The same exact code is working when not inside a Dialog so just wondering if this is something that isn't allowed/suggested. The error points to ModalManager so it does seem related to being inside the Dialog.
Thanks,
Mark

Joi Validation Accepts undefined When Required

I have a validation issue I am hitting while using Joi. I have a set of number fields that begin with a value of undefined but are ultimately required. However, Joi still accepts the undefined values upon submit.
expenses: Joi.number().min(0).max(9999999).required()
I have found that once I load the form and click submit, the values are accepted. However, if I type into a field, say 1 and then backspace to remove it, then the field does error on submit.
Any way I can get the undefined to trigger the error on the number field with the initial submit?

Get page background

How can I access the style information for a tab? The following code logs an empty object.
tabs.activeTab.attach({
contentScript: 'self.port.emit(console.log(unsafeWindow.document.body.style);'
});
First off, you are missing a ) in your content script. Then you are returning the return value of console.log to the port.
However I am going to assume, that you are getting an empty object in the page's console from that console.log. The document.body.style attribute may still be empty, since that only holds the value of the inline style attribute of an HTML element (see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style).
You would probably have to parse document.styleSheets or use the developer tools API to the get the currently rendered background.

html2canvas Error : Uncaught TypeError: undefined is not a function

I have used the below code to generate the screenshot of a grid in my page. The 'gridBody' in the code below is a DOM object.
html2canvas(gridBody ,{
onrendered:function(canvas){
var img = canvas.toDataURL();
window.open(img);
}
});
But it gives an error:
Uncaught TypeError: undefined is not a function (html2canvas.js:2191)
_html2canvas.Preload (html2canvas.js:2191)
(anonymous function)
line 2191 in html2canvas.js file:
domImages = element.getElementsByTagName('img'), // Fetch images of the present element only
This works absolutely fine when i give 'document.body' instead of 'gridBody'.
Can you please help me out, why is the error coming?
Note: gridBody DOM starts and ends with
<div>
tags. I can share it, but this space doesnt allow to paste the entire DOM here, and i dont see any way to attach a file.
I had this problem, and found that it was due to the selector that was passed in to html2canvas being empty. This resulted in 'element' not being an element.