Link's coded in rich text do not work properly.

Originally, I had an issue with the rich text editor resetting the formatting of my content almost every attempt I made formatting. I was able to solve that issue by writing the content strictly using the “html” editor instead of the “visual” text editor.

The Situation:

  1. I have a dynamic page with additional datasets connected to page elements.
  2. dataset5 (not dynamic) connects my TakeAction collection to Table.
  3. Table 3 has also has an onRowClick event handler that retrieves the item, sets a text element equal to the item’s “instructions” property value, and expands the box containing the text element.
export function table3_rowSelect(event) {
    let selection = event.rowData;
    let itemId = selection["_id"];
    wixData.query("TakeAction")
        .eq("_id", itemId)
        .find()
            .then( (results) => {
                let item = results[0];
                let action = item.instructions;
                $w("#text3A").html = action;
                })
                .catch( (err) => {
                    let errorMsg = err;
                })
                .then($w("#fold3C").collapse())
                .then($w("#fold3A").expand());
}

Link Behavior:
If the page is freshly loaded, when the table has a row for the first time, it works as intended. The box expands, the text is displayed in the appropriate format, and selecting a link contained in the now displayed text element opens the URL. Also of note, the link can be selected multiple times, opening each instance.

If you then select a second link in the same element, it will not open, at which point the the first link also stops working.

If you then select another row from the table, to repopulate the text element with new instructions and a fresh set of links, they don’t open, but refreshing page makes it work, until trying to select another link.

I’m having a hard time determining what the root cause is because it doesn’t always do the exact same thing. Sometimes a particular link from a row will the entire time, even while the other links from other rows stop.

Hi,
Have you used console log to check whether you get the correct _id ?
I would try using console log to check whether you set an actual id to the itemId variable.
I recommend checking out the tips mentioned here to learn how to debug your code.

Best,
Tal.

Thank you for your reply.

I know the “_id” is correct because the appropriate text with the links is displayed when I select each row. The problem is that the links within that text only work sporadically.

Since my OP, I’ve spent over an hour on the phone with Wix support who told me that everything looked to be connected correctly and that the issue is a bug, so they referred me to another person by email. That person replied back and told me that it must be something I did wrong with the JavaScript.

In the meantime I have tried everything from retrieving the item from the database via query, get, filtering the database, and indexing. None of that fixes the issue.

Even though I do not see anything wrong with my coding, I went ahead and created a new database and an entirely new page without using any JavaScript but it behaves exactly as it did before.

Here’s a video showing what happens on that new page without any JavaScript:

First I select a row, it populate the info I’m looking for under the table. The first link I select does not work, the second link I select works, the third link I select does not work. Then I back out of preview mode, go back into preview mode, and begin by selecting the third link that didn’t work, which now works, but then the other links don’t work.