I’m trying to change an element’s id in response to an event but I can’t seem to get it to work. I have created a simplified example of what I’m trying to do below.
function handleEvent(e) {
var app = UiApp.getActiveApplication();
app = changeId_(app, 0, 1);
return app;
}
function changeId_(app, idOld, idNew) {
app.getElementById(idOld + "element").setId(idNew + "element");
return app;
}
I’m just wondering if it is actually possible to do as I can’t think of what is wrong with the code.
You should be able to use a grid and replace elements in the grid. When you replace elements in the grid, you can use a new ID for the new element/”widget”.
In my case, I repopulate the entire grid to make the code simple, but I think can replace a single element.
Take care with widget IDs, if you reuse an old ID for a new widget, then ensure the widget type of the old and new widget are the same.