24
Views
9
Comments
Solved
How to edit a specific word in a text?

I have a context like this and its working:


Do you know what is necessary to when a user clicks in a word in the input text open a popup to edit that specific word? For example if the user clicks hover the word "Lorem" it should open a popup and the user can change to "Lorem2", like:


Champion
Rank: #137
Solution

Hey,

I can think of 2 ways of achieving this:

1) Splitting the entire text by " " and displaying a list of single words. Each single word then has its own click event, allowing you to change it

2) With JS you can determine the clicked word using a script such as this one. From there you'll be able to edit your word with some additional logic.

Cheers,

David

Rank: #17267

Hi! Can you explain better the first approach? Thanks!

Champion
Rank: #137

Hey Jake, check my example here. Also attached the OML.

ClickSingleWord.oml

Rank: #17267

Thanks! In the case where I have a text stored in the database do you know how to in the save action update the text with the new word? That is, the text stored in database should be equal only with the updated word different.

Rank: #17267

Maybe is easier to explain with a image the context I have now with your solution:


11.png

Champion
Rank: #137

In the save action you can update the list with the new value and then:

1) use the String_Join action from the Text extension to join all the list elements again OR

2) concatenate all the list elements in a for each cycle with " "

Afterwards you can update the record in the DB.

Rank: #88

Hi Jake B,


I have made one smaple oml for you based on requirment.

You can change it accordingly.

like clik on edit button it will open one pop up for descriptio  and double click on words it will create a input box and you can chnage it from new words

Sample app- Change Word


Hope this will help you.

Regards

Rahul

ChangeWord.oml

Rank: #17267

Hi, can you explain better how it works? It seems that the example is not working.

Rank: #129

Hi Jake,

is there a reason why you can´ t let the user just edit the text, why the clicking and the separate input to change a single word ?

This is awkward for the user and a lot of extra coding and testing work.

If it is an attempt at controlling what sections of a text are up for change, it will probably only work in simple case, as words of a sentence influence other parts of it.

You also risk re-inventing functionality that already exists in word processing software.

Dorine