112
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:


2022-05-19 09-39-13
David Sousa
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

UserImage.jpg
Jake B.

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

2022-05-19 09-39-13
David Sousa

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

ClickSingleWord.oml
UserImage.jpg
Jake B.

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.

UserImage.jpg
Jake B.

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


11.png
2022-05-19 09-39-13
David Sousa

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.

2026-02-26 06-29-24
Rahul
 
MVP

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
UserImage.jpg
Jake B.

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

2021-09-06 15-09-53
Dorine Boudry
 
MVP

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

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.