View Full Version : Edge-to-Edge List

Nov 4, 2008, 04:26 AM
Hi all,

im new to the iPhone dev kit for about a week not and i hit the first problem.

Im using and Edge-to-Edge list. The array data is set in the main.js inside the init funcation like:


where array is in a format of [[row0label, row0value], [row1label, row1value],...] -> thsi array is been created from records which are been store in a DB.

The list gets displayed correctly, but now i want to add a link to a new view. So far i added a handler on the onlick event of the ListRowTemplate insidide the funcation i have the following:


This always displays zero :s and i dont know why :S

Any help appreciated.
Thanks guys.

Nov 6, 2008, 04:32 AM




onClick event



The code you've posted appears to be JavaScript rather than Objective-C. So yes, a little more explanation would help!

Nov 6, 2008, 05:15 AM
Yes I'm developing a webapp in javascript.

Im using a dynamic edge-to-edge list. The list gets displayed correctly :). (see picture :)).

I added a onClick event to the listRowTemplate which just alert's the value been pressed:


If i press / click on item one zero is displayed.
If i press / click on item two also zero is displayed.
If i press / click on item three ALSO zero is displayed.

How do i get the correct value of the pressed value which has been press.

I want to display:

If i press / click on item one: "one been pressed".
if i press / click on item two : "two been pressed".

Anymore question please ask!!

Nov 6, 2008, 05:26 AM
Yes I'm developing a webapp in javascript.

Ah, understood. I'm afraid this forum is for iPhone development (Objective-C) using Apple's SDK, so you're unlikely to find much help here with JavaScript since most of us are not web developers.

You might have more luck here: http://www.webmasterworld.com/javascript/

Re. your code; what value are you trying to retrieve? if you want the actual content of the cell you might want to try innerHTML since the element itself is unlikely to have a value.

Nov 6, 2008, 05:33 AM
Ah, I see, you're after the index of the cell in the table. JavaScript provides the cellIndex method for just this purpose:

<td id="cell1" onclick="index(this);">Item 1</td>
<td id="cell2" onclick="index(this);">Item 2</td>

<script type="text/javascript">
function index(element) {
alert("Cell index is " + element.cellIndex);