Skip to content

CSS not working on Repeater when bindingContext set on 'navigatingTo' #590

@emiloberg

Description

@emiloberg

Easiest described with an example.

Look at this very simple app. It has a Repeater where every item will be a label with the cssClass red, and below them there's a "fixed" label with the text This is always red and the same cssClass.

<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">
    <StackLayout>
        <Repeater items="{{ items }}">
            <Repeater.itemTemplate>
                <Label text="{{ title }}" cssClass="red" />
            </Repeater.itemTemplate>
        </Repeater>
        <Label text="This is always red" cssClass="red" />
    </StackLayout>
</Page>
function pageLoaded(args) {
    var page = args.object;
    page.bindingContext = {
        items: [
            {
                title: 'Test1'
            },
            {
                title: 'Test2'
            }
        ]
    };
}
exports.pageLoaded = pageLoaded;
.red {
    color: #ff0000;
}

So far so good. However, if I change from setting the bindingContext on loaded to navigatingTo, e.g. changing:

<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">

to

<Page xmlns="http://www.nativescript.org/tns.xsd" navigatingTo="pageLoaded">

then no CSS will be applied on the itemTemplate of the Repeater. Instead it will look like this. Note that CSS is still applied to the "fixed" label.

skarmavbild 2015-08-14 kl 16 52 06

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions