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

Web and WebWorks Development

Reply
Highlighted
Developer
Posts: 172
Registered: ‎05-01-2010
My Device: Z10
My Carrier: O2
Accepted Solution

set dynamically onclick event within setAttribute with bbui

[ Edited ]

Hi,

 

what I am trying to achieve is to create a onclick event within a ListItem that is passing a variable to the bb.pushScreen() function. Got it? Smiley Wink

 

1. after a screen is loaded I am creating a dynamically List with items that have a onclick event.

 

listItem = document.createElement('div');
listItem.setAttribute('data-bb-type', 'item');
listItem.setAttribute('data-bb-title', title);
listItem.setAttribute('data-bb-accent-text', combindedDate);
listItem.setAttribute('onclick', "bb.pushScreen('page.htm', 'page', '666');");

 

2. when clicked on the item a new page is opened, because of the onclick attribute. (working fine)

 

The additional option (666) needs to be a variable. I couldnt figure out how to solve that problem.
There must be some way that I can pass a variable within the new created item to the bb.pushScreen funtion.

 

Any Ideas? Smiley Happy

 

best

 

bert2002

 

 

UPDATE: Just sat down once again and its possible with some escaping:

 

listItem.setAttribute('onclick', 'bb.pushScreen(\'page.htm\', \'page\', \''+ itemid +'\');');

 



----------------------------------------------------------
find my widgets -> http://blackberry.itbert.de
BlackBerry Development Advisor
Posts: 762
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: set dynamically onclick event within setAttribute with bbui

Just helped out a friend with the same thing yesterday, it was also an escaping issue..  the 'update' looks proper to me, is it okay now?  

 

 

Developer
Posts: 172
Registered: ‎05-01-2010
My Device: Z10
My Carrier: O2

Re: set dynamically onclick event within setAttribute with bbui


chadtatro wrote:

Just helped out a friend with the same thing yesterday, it was also an escaping issue..  the 'update' looks proper to me, is it okay now?  

 

 


yes is working absolutly fine Smiley Happy



----------------------------------------------------------
find my widgets -> http://blackberry.itbert.de