Edge-to-Edge List

Discussion in 'iPhone/iPad Programming' started by paul.haenel, Nov 4, 2008.

  1. macrumors newbie

    Joined:
    Nov 4, 2008
    #1
    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:

    list.object.setDataArray(array);

    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:

    alert(document.getElementById('listRowTemplate').value);

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

    Any help appreciated.
    Thanks guys.
     
  2. macrumors 6502a

    Joined:
    Oct 24, 2008
    Location:
    Cambridge
    #2
    The code you've posted appears to be JavaScript rather than Objective-C. So yes, a little more explanation would help!
     
  3. thread starter macrumors newbie

    Joined:
    Nov 4, 2008
    #3
    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:

    alert(document.getElementById('listRowTemplate').value);

    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!!
     

    Attached Files:

  4. macrumors 6502a

    Joined:
    Oct 24, 2008
    Location:
    Cambridge
    #4
    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.
     
  5. macrumors 6502a

    Joined:
    Oct 24, 2008
    Location:
    Cambridge
    #5
    Ah, I see, you're after the index of the cell in the table. JavaScript provides the cellIndex method for just this purpose:

    Code:
    <td id="cell1" onclick="index(this);">Item 1</td>
    <td id="cell2" onclick="index(this);">Item 2</td>
    etc.
    Code:
    <script type="text/javascript">
    function index(element) {
        alert("Cell index is " + element.cellIndex);
    }
    </script>
     

Share This Page