Reputation: 3690
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!
Upvotes: 0
Views: 315
Reputation: 33
Please make sure you first enable Redactor on the same element, i.e. you call
$('#eg_description').redactor(); //you can provide options object here
Upvotes: 0