0

I'm trying to get a rich text field from the DOM and save it via javascript and its Sharepoint Client Context.I have an XSL form that creates a Sharepoint Form Field with a structure that's something like:

<div>
  <div>
    <div> 
      RTE field (changes from p tag to h1/h2 depending on style)
    </div>
  </div>
</div> 

I've tried numerous different (and sometimes rigged) ways of doing this:

$('myRTEID').html();
$('myRTEID *').html();
$('myRTEID').last().val();
var myHtml = document.getElementByID('myRTEID').firstChild.innerHTML;

Many more than the above attempts did not work either. The issue I'm running into, and partially the reason is due to nested tags, is that I can get the proper value, markup and all, but only if it is the default style. On top of this, even if it is set to the default style, bold and italic (strong and em) tags are picked up, but anything more than this will cause the exact same method of retrieving the DOM element to return undefined. Any insight into this would be greatly appreciated, as I have officially exhausted my attempts.

-1

The solution ended up being:

$($("[id*=ff681][id$=inplacerte]")[0]).html();
  • Why does this have a negative response? Seems to work for me, but still doesn't drill down far enough... getting a response of <div class="ExternalClassFDC8776178884911AD86361735106BB4"><p>cd<strong>ddd</strong>d</p></div>... whereas I just want the value – southskies Apr 20 '17 at 5:18
  • My code $($("[id^=<value>][id$=inplacerte]")[0]).children().html seemed to have the exact outcome I was seeking. Whats wrong with that code? – southskies Apr 20 '17 at 5:48
  • @southskies I'm not sure, I've submitted multiple posts/comments and I seem to get downvoted a lot, but I have no idea why. Thanks for your input! – JOdom Apr 21 '17 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.