Component references in LibJS are always an instance of one of the component classes found in the u-components module. You can not create new instances of a component using these classes, but you can manipulate an existing component in your app using the properties and methods that each component class exposes.
This example shows a few different ways of getting a component, and interacting with them.
newAction('Fade Image', fadeImage).register(); functionfadeImage() { varlogoImg = uPages.current.components.getImage('Big Logo'); logoImg.filename = 'umajin_logo.png'; logoImg.alpha = 30; console.log(logoImg.height); varhomePage = uPages.get('Home Page'); // Better to use `getButton` here, but using `get` and passing in the type as an argument is always an option. varmyBtn = homePage.components.get('My Button', uComps.ComponentType.BUTTON); myBtn.on(uComps.ComponentEvent.PRESS, function() { console.log('Button has been pressed!'); }); }
If you need to find all the components within a page, you can use the innerComponents property as this example shows:
Component references in LibJS are always an instance of one of the component classes found in the
u-components
module. You can not create new instances of a component using these classes, but you can manipulate an existing component in your app using the properties and methods that each component class exposes.This example shows a few different ways of getting a component, and interacting with them.
If you need to find all the components within a page, you can use the innerComponents property as this example shows: