01-12-2013 11:26 AM - edited 01-12-2013 06:33 PM
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?
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.
UPDATE: Just sat down once again and its possible with some escaping:
listItem.setAttribute('onclick', 'bb.pushScreen(\'page.htm\', \'page\', \''+ itemid +'\');');
Solved! Go to Solution.
01-14-2013 09:18 AM
01-14-2013 03:12 PM
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