facebook

List Menu

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #334556 Reply

    Brandon
    Member

    I have a list menu (the one with the check marks) that triggers a javascript. What I need is when the javascript has completed to automatically select the next item and fire off the javascript in that item.

    I have found lots of code for deselecting an item, even all items, but nothing for deselecting the current item and selecting and executing the next one.

    Any help is appreciated.

    #334573

    @CincyPlanet,

    I’ve made some modifications to code in next thread: http://www.genuitec.com/support-genuitec/viewtopic.php?p=8909#p8909

    
    var index=0;
    function selNext(){
    // Note: m1-unselect-list1 is an ID 
    // of <ul> element, taken from TC/Tools/DOM Inspector
    var selListId = 'm1-unselect-list1';
    var listName = 'list1';
    var totalItems= $('#' + selListId + '> li').size();
    
    //check if final item is selected, if yes, select the first item making index 0 again
    if(totalItems-1==index){
      index =0;
    }
    else{
      index++;
    }
    
    var itemToSelect = index;
    
    var selId = $('#' + selListId + '> li').each(
    function (i) {
      $(this)[i == itemToSelect ? 'addClass' : 'removeClass'](m1Design.css("selected"));
    });
    
    // This line updates hidden select, for the case the whole 
    // design will be used as a form
    phoneui.preprocessDOM('#' + selListId);
    
      }

    So, you should call a similar function like this one, when you want to select the next item in your listitems. Hope this make sense, let me know how it goes for you.

    #334576

    Brandon
    Member

    Thank you. I kind of have it working.

    How do I get the currently selected items index value?

    #334637

    Brandon
    Member

    Any tips on getting the currently selected list item? I still havent been able to figure it out.
    Thanks

    #334691

    @CincyPlanet,

    We will help you on this matter tomorrow after I get feedback from dev team to give you the better advice.

    #334708

    Brandon
    Member

    Ok, thank you.

    #334842

    Brandon
    Member

    Any news on how to do this?

    #334846

    Hi CincyPlanet,

    Try something like this:

    function getSelectedIndex(){
    
        var selListId = 'm1-unselect-list1';
        var listName = 'list1';
    
        var selId = $('#' + selListId + '> li').each(
        function (i) {
    
        if ($(this).hasClass('m1-selected')){
            index=i;
            }
      
        });
    
        phoneui.preprocessDOM('#' + selListId);
    
    }
    #334849

    Brandon
    Member

    Thanks, I will try it tonight and let you know how it works.

    #345506

    Code_A
    Member

    Try this:

    var selectedIndex = $('select[name="lstName"] :selected').index();
Viewing 10 posts - 1 through 10 (of 10 total)
Reply To: List Menu

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