facebook

Clearing a select list

💡
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 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #346389 Reply

    Hello,
    I was wondering if i could make a button in mobione that, when pushed, would clear all the selected items off a select list, making it so that no list items were selected. Bear with me, as I don’t have a whole lot of experience in programming, so it may seem that I’m asking obvious questions.
    Thanks,
    Phil

    #346391

    Code_A
    Member

    Just to clarify, do you want to:

    1) clear all items from the list
    2) clear all the check marks from the list
    3) clear only the items from the list that are selected

    #346392

    I wish to deselect the selected list items, thus returning the list to state where no items are selected.

    #346393

    Code_A
    Member

    Not sure if this is the best way or not, but it works.
    Reference this post: viewtopic.php?f=8&t=6617

       var selListId = 'm1-groups-list1';
       var itemsToSelect = -1;  //set number to default selected item, -1 for none
       var selId = $('#' + selListId + '> li').each(
       function (i) { 
           $(this)[i == itemsToSelect ? '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);
    Attachments:
    You must be logged in to view attached files.
    #346398

    Code_A
    Member

    This code is a little cleaner if you just want to clear all the selections.

    var selListId = 'm1-groups-list1';
       $('#' + selListId + '> li').each(
       function (i) { 
           $(this).removeClass(m1Design.css("selected"));
           }
       );
       phoneui.preprocessDOM('#' + selListId);
    #346410

    Paul_paul
    Participant

    I use this seems to work ok, I’m not good at JS but trying to learn.
    Use on button – run javascript- confirmListClear()

    Copy to custom.js file

    function clearList() {
    $(‘.m1-selection-list > li’).each(function (i) {
    $(this).removeClass(m1Design.css(“selected”));
    });
    phoneui.preprocessDOM();
    }

    function confirmListClear() {
    var theAnswer = confirm(“OK to Clear List?”);
    if (theAnswer){
    clearList();
    }
    else{
    alert(“List Not Cleared”);
    }
    }

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Clearing a select list

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