7

I have been struggling with this for a few days now, and I have tried many different ways (i.e. wrong ways) to get the correct events to fire so that when the contents of the RTF's Source Tab (which is now a CodeMirror Area)

I have the CodeMirror ability on both the Component's main source tab and the RTF fields Source Tab. Switching between the tabs works okay, and initializing CodeMirror on any of the source tabs works well, saving works well, everything seems to work well except for ONE thing.

Scenario 1:

Open component, go to RTF source tab, enable CodeMirror, change content, click design tab, contents of design tab are updated, click the main component source tab, contents are updated (to what was changed in the CodeMirror area) == OK

Scenario 2:

Open component, go to RTF source tab, enable CodeMirror, change content, click the main component source tab, contents are NOT updated (to what was changed in the CodeMirror area) == NOT OK

I cannot get the correct behavior to trigger the updating of the contents when going directly from the RTF source tab with CodeMirror enabled.

Please, suggest any additional triggers I may fire when the contents of the RTF is changed so that the main source tab's contents is also then updated?

Things I have tried that did not work, or I did wrong...

  • I have tried to fire the onchange event on the original text area.
  • I have tried to set the "updated" flag on the SourceArea (Tab) property.
  • I have tried turning the CodeMirror back to TextArea, which is then updated with the correct content, but even then when switching to the main source tab, the contents are not updated, which is crazy!
  • I have tried banging my head against the screen and many other angles

I can share the code with someone that needs it.

  • Is your code correctly updating the Component Model object when changes occur? I would expect that to be all that is needed... – Peter Kjaer Jun 1 '17 at 8:06
  • I would say it is not. I have tried to look into the GUI code to see where/how I would be able to do this, but have not been able to find this. Thank-you for your input!! The only think that I am updating so far is the text area (original) and when changing to the design/preview I guess it is automatically then updating the Component Model, but it does not do so when changing to the main Source tab. Could you show me how I would update the Component Model please? – Bradley Pennington Jun 1 '17 at 16:47
  • $display.getItem().setContent(xml) for example. – Peter Kjaer Jun 2 '17 at 8:49
  • Can you catch the lost focus. E.g. document.getElementById("rtf-field-name-somehow-retrieved-dynamically").onblur=alert("do something here"); – Dylan .. Mark Saunders Jun 6 '17 at 12:41
  • Please check with SDL support team. they will help to you better solution for your requirement. – Sudhakar Rao Dec 12 '17 at 5:24

Your Answer

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

Browse other questions tagged or ask your own question.