cancel
Showing results for 
Search instead for 
Did you mean: 

How to change Html Body control with dynamic string?

former_member185620
Participant
0 Kudos

Hi guys,

I want to change my string when button then refresh html body control.

I use below code but I can't change string content.

Edit fiddle - JSFiddle

How can i do this.

Thanks for help.

Burak Oral

Accepted Solutions (1)

Accepted Solutions (1)

former_member182862
Active Contributor
0 Kudos

I think I will do it this way 🙂

JS Bin - Collaborative JavaScript Debugging

-D

Answers (1)

Answers (1)

Qualiture
Active Contributor
0 Kudos

You never change the value of variable 'dynamicString' with the changed 'found/found2' variables, that's why it appears as if it wasn't changed

former_member185620
Participant
0 Kudos

Thank you. I know. Do you have any suggestions solution ?

Qualiture
Active Contributor
0 Kudos

Euh, yeah? How about set the text not on a variable (which isn't visible of course) but on a DOM object

This should work:


var dynamicString = '<div id="P_STRING">String 1</div> ----------- <div id="P_STRING2">String 2</div>';

var oButton = new sap.ui.commons.Button({

    text : "Change",

    press : function(){

         $("#P_STRING").text("Changed String 1");

         $("#P_STRING2").text("Changed String 2");

    }

});

former_member185620
Participant
0 Kudos

Thanks for help

I found a solution in a different way.

Private_Member_15166
Active Contributor
0 Kudos

Would you mind to share the solution?

Perhaps this will help to many users.

former_member185620
Participant
0 Kudos

I gave up using div and I use string.replace method.

Qualiture
Active Contributor
0 Kudos

I may seem like a broken record since i mention this every 3rd topic it seems, but:

If you want to display / change text on your screen, why not use a Model?

former_member185620
Participant
0 Kudos

Actually I'm using Rich Text Editor and I would like to dynamically changing content in rich text editor.

Qualiture
Active Contributor
0 Kudos

Ok, if you are trying to manipulate generated HTML in the RichTextEditor control's "value" property, then I can more or less understand

However, in that case, I think a cleaner approach would be to extend the RichTextEditor itself, since that is the control that is responsible for any style/content changes anyway