facebook

Populate Custom List Example: UPDATED Oct 24, 2013

  1. MobiOne Archive
  2.  > 
  3. Examples, HOW-TOs
Viewing 15 posts - 16 through 30 (of 42 total)
  • Author
    Posts
  • #327813 Reply

    Unknown Author
    Participant

    Thank you! I’m sure this line is the issue. The rest of my JavaScript double custom list code is working.

    -1TC

    #327937 Reply

    Unknown Author
    Participant

    I think I have found a solution to fix your custom list example.

    Replace
    var selectListItemLabel = $(“div > div”, $(event.srcElement)).text();

    With this:
    var selectListItemLabel = $(event.srcElement).text(); //grab the label
    selectListItemLabel = selectListItemLabel.replace(/^\s+/g,”); //replace leading spaces
    selectListItemLabel = selectListItemLabel.replace(/\s+$/g,”); //replace trailing spaces

    -1TC

    #327958 Reply

    support-michael
    Keymaster

    @1thinchip

    I finally got a few mins to investigate what might be up. There is definitely a bug in the example code, updateLandingScreen().

    function updateLandingScreen() {
       var selectedListItemIdx = $(event.srcElement).attr('data-listitem-index');
       $('#m1-landing-indexTxt').text(selectedListItemIdx);
    }

    List-item HTML Implementation

    
    <li id="m1-list-listItem1" class="m1-first m1-last m1-clickable m1-highlight 
           m1-hyperlink-internal" data-action-click-id="action0" data-listitem-index="1">
        <div id="m1-list-listItem1-inner-div">
             <img id="m1-list-accessoryImage1" class="m1-clickable" 
                 src="res/images/tableRowDisclosureIndicator.png"/>
             <div id="m1-list-text2" class="m1-text">Item</div>
        </div>
    </li>

    The flaw is this function assumes that selecting anywhere in a list-item will return the top-level <li> for the list-item. This is incorrect, at least in 2.0. I found that the event.srcElement can be any child element under the <li> that is touched. Thus the event.srcElement can be the <div> child of the select <li> or it could be the <div> for the text label or the accessory-image on the right.

    In order to access the list-item’s data-listitem-index attribute and the label of the list item you should use the following snippets

    //get the data-listitem-index of selected list-item
    $(event.srcElement).closest('li[data-listitem-index]').attr('data-listitem-index')
    
    //get the label of the selected list-item
    $('#m1-list-text2',$(event.srcElement).closest('li[data-listitem-index]')).text()

    Lastly I found a bug if the ‘>’ disclosure image is clicked as it is not inheriting the list-item’s action and firing it correctly. The dev team knows of this issue and it will be resolved in next release.

    #327959 Reply

    support-michael
    Keymaster

    all: octavio and I are working to update the custom-list example for 2.0 to fix a bug. We will post an update late today (fri) or this weekend as time permits.

    #327961 Reply

    Unknown Author
    Participant

    Excellent! I appreciate all the hard work you and Octavio put in supporting the developer community!

    -1TC

    #327972 Reply

    support-michael
    Keymaster

    I updated the example a few mins ago for MobiOne 2.0. It also demonstrates accessing a selected list-item’s label as well as its index in the list.

    See http://www.genuitec.com/support-genuitec/viewtopic.php?f=14&t=1858

    #328327 Reply

    geebee
    Member

    Great example. Two things I’ve noticed:

    – When I create a list of 15 items which is more than the page height, only half of the last item (Item-15) shows. Even if you scroll up, once you let go, it resets itself so that only half of the individual list area shows.
    – When I go to the detail of item 14 and then go back to the list page, the list position resets itself to the top, instead of showing items 6 through 15 (half of 15, actually) which were displayed before I selected to view the detail.

    I know the second question of the list repositioning itself has been tossed around before, so I apologize that I can’t pinpoint the exact thread.

    If you could comment on this it would be appreciated.

    #328331 Reply

    Unknown Author
    Participant

    I tried this on my own app (“My Comic Books” on iTunes). I created a list of 21 items and it works just fine. I suspect that you’re not increasing the size of your panel dynamically. Take another look at the code example – right at the end you increase the size of the panel the list is in

    #328334 Reply

    geebee
    Member

    I didn’t change anything – I’m running the stock demo as downloaded and opened in MobiOne.

    #328348 Reply

    Hi geebee,

    You need to increase the content area height off the transparent panel in the example. Note in the next image the buttons and + to increase or decrease it or you can set the customized value in the content area height property

    #329837 Reply

    Max87
    Member

    Hi guys,
    I downloaded this example and when I open it, it works fine.
    But I have a problem – when I customize the code, my custom list is not generated properly. My workaround is that I add this mobi files and asociated _custom.js to my project – it’s not so good, but it works for now.
    I have another problem – I add this example to my project, generate random number of list item, when I touch the list item, it’s supposed to transfer me to landing screen – instead od landing screen, main screen is displayed. I have onClick action set to go to landing page in Design Center(assigned main.js action is action8), but it’s not working. I looked in main.js(generated, not custom) and there is action0 set to go to main screen. If I overwrite this action0 and set it to landing screen, it’s working fine. I don’t understand this behavior, because my list item has set action, this action is generated in main.js as action8, but when I click on list item, it trigers action0.
    Please help me to solve this, it’s very important for my app.
    Thank you.

    #330762 Reply

    Hi Max,

    We have a fix for this. It will be avail in next MobiOne version that we plan to release soon.

    #330781 Reply

    Unknown Author
    Participant

    I’ve had this same problem. If you’re near the end of your development, just compile a version with the current, working, action numbers and upload that to Apple. That’s what I did.

    #330783 Reply

    Max87
    Member

    Hi guys,
    2 Octavio: That’s great news, that you have fix for this
    2 1thinchip: thanks for suggestion, my project isn’t in the RTM state 🙂

    #331055 Reply

    Max87
    Member

    Hi guys,
    I’m trying to show select from database into custom list and write results from that select.
    My problem is, when I call Select function from Test center’s console and then buildList function, almost everythng goes ok.
    But If I want to run this two functions by clicking on button, select function runs, but buildList function removes first list item and doesn’t create all others.
    Second problem I have is Panel height. Panel is scrollable, but I can’t get it working, when I call this functions by button. When I call it by TC console, panel height is OK.
    Can you guys please look at it? Can I send you my project?
    Thank you.

    edit: I solved it! I call B function(build list) inside A function(select from dtb) with 5s timeout and it’s working!

    edit2: I have small issue with panel height. When I first call the A function to select from dtb, it calls B function, which generates custom list and sets panel height. That’s ok.
    But when I ran another function to filter dtb selection by date, A and B functions are called fine, but panel height is not updated – it’s “computed” – variable has new value, but screen is not updated with that value…
    I use: panelHt = 30 + itemCnt * 44;
    $(‘#m1-main_screen-panel1-scroller’).attr(‘data-layout-content-height’, panelHt);
    phoneui.preprocessDOM(‘#m1-main_screen_main-panel1’);
    Can you help me with this please?
    Thanks

Viewing 15 posts - 16 through 30 (of 42 total)
Reply To: Populate Custom List Example: UPDATED Oct 24, 2013

You must be logged in to post in the forum log in