Dashboard item moves when opening a new window.

You must Login before you can answer or comment on any questions.

Hi!

I have a funny situation here. Each time I open a window from a dashboard item click event. Before that the new window appears, the items moves. And when I go back, they don't return to the same position.

I put a link to a video showing the problem:

http://www.youtube.com/watch?v=av1xeQY_8uc

And here is the code:

(function() {
 
    ir.ui.createHomeWindow = function() {
 
        var win = Ti.UI.createWindow(ir.combine($$.homeWindow, {  
 
            title: L("AppName")
        }));
 
        var data = [];
        var labels = ['search', 'invite', 'promotions', 'profile', 'about', 'help'];
 
        for (var c = 0; c < labels.length; c++) {
 
            var item = Ti.UI.createDashboardItem({
 
                image: 'images/dashboard/' + labels[c] + '_' + ir.locale({
 
                    fr: 'fr',
                    en: 'en'    
                }) + '.png',
 
                label: labels[c]
            });
 
            data.push(item);
        }
 
        var dashboard = Titanium.UI.createDashboardView({
 
            data: data,
            top: 50,
            canDelete: false
        });
 
        win.add(dashboard);
 
        var cancel = Titanium.UI.createButton({
 
            systemButton:Titanium.UI.iPhone.SystemButton.DONE
        });
 
        cancel.addEventListener('click', function() {
 
            dashboard.stopEditing();
        });
 
        dashboard.addEventListener('edit', function() {
 
            win.rightNavButton = cancel;
        });
 
        dashboard.addEventListener('commit', function() {
 
            win.rightNavButton = null;
        });
 
        dashboard.addEventListener('dragStart', function(e) {
 
            win.rightNavButton = null;
        });
 
        dashboard.addEventListener('dragEnd', function(e) {
 
            win.rightNavButton = cancel;
        });
 
        dashboard.addEventListener('click', function(e) {
 
            var child = null;
 
            switch(e.item.label) {
 
                case('search'): {
 
                    child = ir.ui.createSearchWindow();
                    break;
                }
 
                case('share_food'): {
 
                    ir.ui.createShareFoodWindow();
                    break;
                }
 
                case('top_rated'): {
 
                    child = ir.ui.createTopRatedWindow();
                    break;
                }
            }
 
            if (e.item.label != "share_food") {
 
                win.tabGroup.activeTab.open(child);
            }
        });
 
        return win;
    }
})();

2 Answers

Hello,

when you come back, are you redrawing the dashboard? Can you show more code, specially the logic of what happen when you create the second window and you close the second window.

Best,

Mauro

Hi,

no I'm not redrawing the dashboard and there's no special logic for the closure of the window since it's a navBar. So, it's just a hint of the back button.

Here the code for the open:

var child = ir.ui.createSearchWindow();
    win.tabGroup.activeTab.open(child);
Here's what inside the createSearchWindow:
(function() {
 
    ir.ui.createSearchWindow = function() {
 
        var win = Ti.UI.createWindow({
 
            title: L("Search")
        });
 
        var searchLabel = Ti.UI.createLabel({
 
            text: L("WhatEat"),
            top: 90,
 
            font: {
 
                fontSize: 20,
                fontWeight: 'bold'
            },
 
            width: 'auto',
            height: 'auto',
            color: '#802B20'
        });
 
        win.add(searchLabel);
 
        var searchInput = Ti.UI.createTextField({
 
            color: '#336699',
            height: 50,
            top: 150,
            width: 300,
            hintText: L("SearchHint"),
            borderStyle: Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
        }); 
 
        win.add(searchInput);
 
        var searchButton = Ti.UI.createButton({
 
            title: L("Search"),
            top:210,
            width: 300,
            height: 50,
 
            font: {
 
                fontSize: 20,
                fontWeight: 'bold'
            },
 
            color:'#802B20'
        });
 
        win.add(searchButton);
 
        return win;
    }
})();
Nothing very fancy.

Thanks,

Daniel

Your Answer

Think you can help? Login to answer this question!