Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

How do you update a button's graphic when it is on two separate views?

$
0
0

I have a scrollable view with two child views and want to update the style of the button that's on both views.

<Alloy>
    <Collection id="device" src="Device" instance="true"/>
    <Window id="win">
        <ScrollableView  id="scroll" class="container" showPagingControl="true">
            <TableView class="tableView" dataFilter="filter1" dataCollection="$.device">
                <Require src="scrollTVRow" />
            </TableView>
            <TableView class="tableView" dataCollection="$.device">
                <Require src="scrollTVRow" />
            </TableView>
        </ScrollableView>
        <View>
            <Button id="closeBtn">Close</Button>
        </View>
    </Window>
</Alloy>
Then the tableView has rows like this:
<Alloy>
    <TableViewRow id="deviceRow" class="deviceTableViewRow">
        <Label class="deviceRowLbl" text="{displayName}" />
        <!--<Button id="btn" class="deviceRowBtn" title="{displayName}" />-->
        <Button id="btn" class="deviceRowBtn" />
    </TableViewRow>
</Alloy>
I populate the TableView with a collection of models and I'm using a filter on the first view so it only shows one button.
function filter1(collection){
    return collection.where({
        address:"18256.0"
    });
}
The second view doesn't have a filter so all of the buttons show up including the first. When I click on the button I want it to change colors on both views. How do I do this? I know I can modify the model in the scrollTVRow.js like this:
if ($model) {
    $.deviceRow.model = $model.toJSON();
    var displayName = $model.get('displayName');
    $.btn.title = displayName;
 
    $.btn.addEventListener('click', function(){
        $model.set('displayName', "blah");
    });
}
and it will apply to both so I can change data like the title and so on but how do I change the style of both?

Thanks.


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>