Results 1 to 4 of 4

Thread: Getting and Removing Button Classes

  1. #1
    Sencha User
    Join Date
    Apr 2007
    Posts
    138
    Answers
    1

    Default Answered: Getting and Removing Button Classes

    I have a project that contains a segmented button. Upon initialization, the first button gets assigned a class of 'lastPressed'. Each time one of the segmented buttons are toggled, I want to:

    1. Remove the 'lastPressed class from any of the buttons
    2. Add the 'lastPressed' to the pressed button


    Number 1 (above) is where I am having the problem. For some reason I can't seem to be able to get the element with the 'lastPressed' class in order to remove the class. Any help?

    Additionally, I want to be able to get the button that contains the 'lastPressed' class and determine its order in the array of segmentedbutton innerItems. How might I be able to accomplish this?

    Here's a Fiddle for reference:


  2. Hi Cybjorg--

    The approach I took (see Fiddle below) was to loop over the items of the SegmentedButton. Within the loop, I check to see if the current item contains the class (via getCls() and indexOf()); if it does, I pluck the index within the loop which gives me the "position" of the child button within the parent. Then I simply remove the class from each item in the loop and once it's complete, I add the class to the button which was pressed.

    I hope that helps!

    Thanks!
    Joel


  3. #2
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    Hi Cybjorg--

    The approach I took (see Fiddle below) was to loop over the items of the SegmentedButton. Within the loop, I check to see if the current item contains the class (via getCls() and indexOf()); if it does, I pluck the index within the loop which gives me the "position" of the child button within the parent. Then I simply remove the class from each item in the loop and once it's complete, I add the class to the button which was pressed.

    I hope that helps!

    Thanks!
    Joel


  4. #3
    Sencha User
    Join Date
    Apr 2007
    Posts
    138
    Answers
    1

    Default

    Quote Originally Posted by joel.watson View Post
    Hi Cybjorg--

    The approach I took (see Fiddle below) was to loop over the items of the SegmentedButton. Within the loop, I check to see if the current item contains the class (via getCls() and indexOf()); if it does, I pluck the index within the loop which gives me the "position" of the child button within the parent. Then I simply remove the class from each item in the loop and once it's complete, I add the class to the button which was pressed.

    I hope that helps!

    Thanks!
    Joel
    Brilliant! You're a life saver. Many thanks!

  5. #4
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    Sure thing, happy to help!

    Thanks
    Joel

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •