Im retrieving some text via an ajax call (Json) and want to populate the html editor with this text. The html editor is inside a form. I cant get it to work. I get an instance of the form, then try to locate the html editor within that form and finally place the data inside it. Heres the code ive used so far
var frm = document.querySelector("#frmAddDisclaimer"); if ("htmlEditorDisclaimer_editor" in frm.elements) { frm.elements["htmlEditorDisclaimer_editor"].value = data.DisclaimerText; }
the frm varaibale exists and has properties and data.DisclaimetText has text in it, but the control isnt being populated. How can I do this ?
Hello mark,
Thank you for posting in our forums!
I understand you are experiencing some issues with the igHtmlEditor in your form.
Firstly, you should use the igHtmlEditor's setContent method rather than modifying the value through the DOM elements. The following code snippet provides a demonstration of how this can be achieved:
$("#htmlEditorDisclaimer").igHtmlEditor("setContent", data, "html");
You can find information on posting data to the server in our documentation here.
I have also attached a sample that demonstrates how you can achieve this in a form with the igHtmlEditor.
If you need any further assistance with this, please let me know.
even if I type completely new text, it still fails validation beacuse the text is empty, yet ive typed some in !
after some searching I eventually came up with this which put the html in the control
$("#htmlEditorDisclaimer").find("iframe").contents().find("body").html(data.DisclaimerText)
but now when I submit the form, it fails validation (modelstate is not valid) because mvc thinks the DisclaimerText is empty !
can anyone help me out here ? this is quickly becoming a joke
Ive changed the code to this
if ("htmlEditorDisclaimer_source" in frm.elements) { frm.elements["htmlEditorDisclaimer_source"].value = data.DisclaimerText; }
which does find the control in the form and assigns it the value in data.DisclaimerText
but the control is still empty, no text is displayed