Results 1 to 7 of 7

Thread: Carousel getActiveItem returns NULL

Hybrid View

Previous Post Previous Post   Next Post Next Post
    Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    86
    Vote Rating
    -7
      0  

    Default Carousel getActiveItem returns NULL

    Carousel was just created with a single item containing some html text. Calling getActiveItem returns NULL. Seems like it should return the item it is displaying.

  2. #2
    Sencha User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,050
    Vote Rating
    1382
      0  

    Default

    Using 2.0.0, 2.0.1 and 2.0.1.1 it is returning the instance for me:

    Code:
    var carousel = new Ext.carousel.Carousel({
        fullscreen : true,
        items      : [
            {
                html : 'foo'
            }
        ]
    });
    
    console.log(carousel.getActiveItem());
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    86
    Vote Rating
    -7
      0  

    Default

    Too fast on the draw there.
    This fails.

    Code:
    var carousel = new Ext.carousel.Carousel({   fullscreen : true,
       items: [{
            xtype: 'label',
            html: 'No Images',
        centered: true }]
       
    });
    
    
    
    
    
    
    console.log("Active Item: " + carousel.getActiveItem());
    
    produces Active Item: undefined

  4. #4
    Sencha User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,050
    Vote Rating
    1382
      0  

    Default

    That's because the centered config makes that item floating and therefor not an inner item. Only inner items can be active therefore getActiveItem will return null.

    If you do this it will work:

    Code:
    var carousel = new Ext.carousel.Carousel({   
        fullscreen : true,
        items      : [
            {
                xtype : 'label',
                html  : 'No Images'
            }
        ]
    
    });
    
    console.log('Active Item: ' + carousel.getActiveItem());
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  5. #5
    Sencha User
    Join Date
    Apr 2012
    Posts
    86
    Vote Rating
    -7
      0  

    Default

    That is a pretty bizarre constraint. There are no warnings in the docs about this sort of thing at all.

  6. #6
    Sencha User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,050
    Vote Rating
    1382
      0  

    Default

    It's not really a constraint, same reason a docked item cannot be an active item.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  7. #7
    Sencha User
    Join Date
    Aug 2012
    Posts
    2
    Vote Rating
    0
      0  

    Default

    Quote Originally Posted by CarClub View Post
    That is a pretty bizarre constraint. There are no warnings in the docs about this sort of thing at all.
    I agree, not that it's a bizarre constraint because it makes sense, but it should be documented.

Posting Permissions

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