Widget Instance

Hi, does anyone know how to get the widget instance value?
When the user add a widget I want to know the instance id that was created… I need this information inside the widget… not in the main app…

Thank you for your time…

Hello,
Please check this
image

The Web widget applications support the following events: onload , onclick , and visibilityChange :

  • onload This event is generated when the Web widget content is loaded onto the widget board. Use it to implement Web widget initialization procedures. For example, initialize Web widget configurations by reading shared data from the parent Web application.
<!--HTML-->
<element onload="load">
/* JavaScript */

/* Define the event */
object.onload=load;

/* Set the event listener */
object.addEventListener('load', load);

/* Define the event handler in the main.js file */
function load() {
    /* Load water data from shared file */
    loadWaterData();

    /* Change the current amount of water */
    document.getElementById('currentWaterNum').textContent = currentWaterNum;

    /* Change the color of the water cups */
    for (var i = 1; i <= currentWaterNum; ++i) {
        document.getElementById('watercup' + i)).style.backgroundColor = 'blue';
    }
}

https://docs.tizen.org/application/web/guides/applications/web-widget/#event-handling

Also please check Widget lifecycle,
https://docs.tizen.org/application/web/guides/applications/web-widget/#life-cycle

Thank you,
Iqbal
Samsung Developer Program

1 Like