Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 240
Registered: ‎01-31-2013
My Device: Developer
Accepted Solution

.. .qml:141: ReferenceError: Can't find variable: cppObject

Hi,

 

I'm getting a

 

ReferenceError: can't find variable: cppObject

 

within the following code,  if I execute the same formatCurrency from within the triggered event everything works okay.,

 

I am trying to format a float currency value before presenting it to the screen, 

 

ListView {
                id: searchListView
                dataModel: searchDataModel
                listItemComponents: [
                    ListItemComponent {
                        type: ""
                        SearchResultsListItem {
                            title: ListItemData.Title
                            pubPrice: cppObject.formatCurrency( parseFloat(ListItemData.Price) ) 
                        }
                    }
                ]
........

 



GeoYeo - Free Local classifieds - Built for Blackberry 10, if you like it please Rate It and Share it!
Developer
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: .. .qml:141: ReferenceError: Can't find variable: cppObject

Hi,

 

ListItemComponents have different context. Something like this should work:

 

ListView {
                function getCppObject() {
                  return cppObject
                }
                id: searchListView
                dataModel: searchDataModel
                listItemComponents: [
                    ListItemComponent {
                        type: ""
                        SearchResultsListItem {
                            title: ListItemData.Title
                            pubPrice: ListItem.view.getCppObject().formatCurrency( parseFloat(ListItemData.Price) ) 
                        }
                    }
                ]
........

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 240
Registered: ‎01-31-2013
My Device: Developer

Re: .. .qml:141: ReferenceError: Can't find variable: cppObject

:Clap:Beauties..  Thank you.. works great...



GeoYeo - Free Local classifieds - Built for Blackberry 10, if you like it please Rate It and Share it!