I have a repeater with two textboxes that display text information from a dataset. The repeater has an onItemReady event handler. The first textbox is directly linked to an item in the dataset, while the second textbox is not. I use the onItemReady event handler to grab text data from the dataset, perform string formatting on the text data, and use it to update the value of the latter/unlinked textbox. The simplified code is found below.
The problem is that in legacy IE, the function runs and updates the textbox with the newly-formatted text, but after running, the text reverts back to the placeholder text shown in the editor (I know this from using console log debugging). This only happens in IE; while Chrome/Firefox/Edge all show the replaced text from the event listener.
I have tried simply running the code within the listener after 1 second with a timeout statement and another workaround (below), but these don’t work. I’m thinking there may be a solution related to using asynchronous execution or different render timing/orders? Is there a fix for this or is it something Wix has to fix on their backend?
// this function is outside of the page onReady function, i.e. the default location of automatically added event handlers
export function repeater1_itemReady($item, itemData, index) {
let strRep = itemData.text_from_dataset
// PERFORM STRING FORMATTING HERE, I KNOW THIS WORKS FINE
// I removed this because it's just a bunch of nested if statements and repetitive string concatenation
// strRep = new_formatted_string
$item("#textbox2").text = strRep;
// #textbox2 is the second/unlinked textbox
}
I have also tried nesting a forEachItem function in the code as such, and get the same problem as previously described.
// this function is outside of the page onReady function, i.e. the default location of automatically added event handlers
export function repeater1_itemReady() {
$w("#repeater1").forEachItem( ($item, itemData, index) => {
let strRep = itemData.text_from_dataset
// PERFORM STRING FORMATTING HERE, I KNOW THIS WORKS FINE
// I removed this because it's just a bunch of nested if statements and repetitive string concatenation
// strRep = new_formatted_string
$item("#textbox2").text = strRep;
// #textbox2 is the second/unlinked textbox
} );
}
The string formatting depends on viewport size and device type, so I cannot simply just add a new item in the dataset where I manually format the text and then link the second textbox. I tried this however to create a “backup” case for use only in IE, but because Corvid doesn’t support browser-dependent code (as far as I can tell), this caused other issues. After linking the second textbox to this new dataset item, the onItemReady event handler code ran BEFORE the textbox was automatically updated with the linked data, which caused the pre-formatted text from the dataset to replace the text written by the event handler. There may be a way to modify this approach by rearranging execution orders? By adding a second linked textbox, would there be any indexing issues?