1

I need to push a page when the list view button was clicked. I have tried the below coding but it is not working.

ListItemComponent {
    type: "imageItem"
    Container {
        id: publicimageItem
         ......

         ......

        ImageButton {
            defaultImageSource: "asset:///defaultimg.png"
            pressedImageSource: "asset:///pressedimg.png" 

            onClicked: {
                var new_page = publicimageItem.ListItem.view.nextpage.createObject();
                publicimageItem.ListItem.view.navigationPane.push(new_page);
            }
            attachedObjects: [
                ComponentDefinition {
                    id: nextpage
                    source: "NextPage.qml"
                }
            ]
        }// ImageButton
    }// Container
}// ListView

When i tried in outside of the listview it will goes to nextpage without any problem.

nonesuchnick
  • 627
  • 4
  • 17
SelvaRaman
  • 218
  • 2
  • 15
  • As a start, add the code from here (http://developer.blackberry.com/cascades/download/releasenotes/#limitations) to your main.cpp so you get output in the console. This is useful for when you want to add debug statements and for displaying errors. – barry Feb 20 '13 at 18:36
  • It also helps for testing/debugging to wrap blocks of javascript code in a try..catch and output the error to the console (if you've implemented barry's suggestion above). Often an error such as "object not found" does not output an error and just silently fails. – hyarion Feb 21 '13 at 10:02
  • Did you find out the solution? – Nam Vu Sep 20 '13 at 09:48

2 Answers2

1

Another simplest way to store the object to global variable using the following code which works fine with me.

     onCreationCompleted: {
     Qt.tabbedPane = tabbedPane;
     Qt.homeTab = homeTab;
    }   

Here I stored tabbedPane in global variable Qt.tabbedPane on page creation Completed.Now I able to access it from ListItemComponent using Qt.tabbedPane.

In your case store the navigation pane to Qt.navigationPane=NavigationId, then try to access it from ListItemComponent as Qt.navigationPane.

Hope it will help.

Hope it helps.

Rian
  • 93
  • 7
0

Suggesting that path to NextPage.qml and the page itself is valid and set up properly, I'd suggest to change the code in onClicked() to the following:

var new_page = nextpage.createObject();
navigationPane.push(new_page);

Please, make sure that navigationPane is accessible here. It might be a good idea to enable console logging (or use terminal slog2info utility) as barry mentioned before. This way you'll be able to see what's happening with your code and why.

As another variant, if you want to navigate to other page by interacting with the whole listitem (not with a particular widget in it), you need to place the same code in onTriggered() slot:

ListView {
    ListItemComponent {
        type: "imageItem"
        Container {
            id: publicimageItem
             ......
        }// Container
    }// ListItemComponent

    onTriggered: {
        var new_page = nextpage.createObject();
        navigationPane.push(new_page);
    }

    attachedObjects: [
        ComponentDefinition {
            id: nextpage
            source: "NextPage.qml"
        }
    ]    
} // ListView    
Community
  • 1
  • 1
Sunseeker
  • 1,503
  • 9
  • 21
  • Hi,is there any method to do single button click if i use onTrigger the whole list is clicking,instead of that need to click a single button click event-Thanks – Vendetta Feb 25 '13 at 07:45
  • What do you mean by 'whole list is clicking'? According to [documentation](http://developer.blackberry.com/cascades/reference/bb__cascades__listview.html#function-triggered-indexpath) this signal is emitted when a list item is triggered by the user. If you want to handle specific signal of a widget within a list item you need to bind to an appropriate signal of that widget i.e. `onClicked()` in case of `Button` and so forth – Sunseeker Feb 26 '13 at 00:16
  • i have this problem : ReferenceError: Can't find variable: navigationPane – Nam Vu Sep 20 '13 at 09:47
  • `navigationPane` is an id of `NavigationPane` object instance. You might change it to whatever your `NavigationPane` object id is assigned. See an example of usage here - http://developer.blackberry.com/native/reference/cascades/bb__cascades__navigationpane.html – Sunseeker Sep 21 '13 at 10:37