Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

Used in TS class constructor doesn't work #4

Open
bradmartin opened this issue Oct 28, 2016 · 1 comment
Open

Used in TS class constructor doesn't work #4

bradmartin opened this issue Oct 28, 2016 · 1 comment

Comments

@bradmartin
Copy link
Contributor

constructor(page: Page) {
        super();

        // Get any view components we need from the interface
/// ALL OF THIS WORK off the PAGE
        this.emailContainer = <GridLayout>page.getViewById('emailContainer');
        this.passwordContainer = <GridLayout>page.getViewById('passwordContainer');
        this.emailTextField = <TextField>page.getViewById('emailTextField');
        this.passwordTextField = <TextField>page.getViewById('passwordTextField');

        console.log(getElementById);

        let y = getElementById('passwordTextField'); // UNDEFINED
        console.log('y: ' + y); 

        setTimeout(function () {
            let x = getElementById('passwordTextField'); /// THIS WORKS
            console.log('x: ' + x);
        }, 0);

}
JS: function (id) {
JS:         return getElementById(getCurrentActiveModel(), id);
JS:     }
JS: y: undefined
JS: x: TextField<passwordTextField>@file:///app/views/login/login.xml:17:25;

So the timeout works with the function, although you can see it is available according to the first log of the function from the plugin.

@NathanaelA
Copy link
Owner

Yeah, I'm well aware of this issue; it is because the NS core framework does NOT setup the currentPage until way WAY late in the cycle; this causes the currentPage to either be null or point to the prior page.

Fix will be available after: NativeScript/NativeScript#2966

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants