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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,323
    Vote Rating
    1294
      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
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,323
    Vote Rating
    1294
      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
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,323
    Vote Rating
    1294
      0  

    Default

    It's not really a constraint, same reason a docked item cannot be an active item.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  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
  •