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 ?
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
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