Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    jQuery Dynamic Selector

    Hi,

    I am trying to implement the tinytabs object (https://github.com/knadh/tinytabs) on my site with dynamically added content. It is working fine with static content, but the tabs are not showing up when I add content after the fact.

    This is my code to initially load the tabs:
    $('#MyTabs').tinytabs({anchor: false});

    I understand I have to use jQuery on with dynamic content, but all online examples use the click event with on, and I can't figure out the syntax to use to connect tinytabs to the new content.

    I can't sem to wrap my head around this. Thanks for any help getting me pointed int he right direction!

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    turn
    Code:
    $(selector).click(function(){...
    into this
    Code:
    $(selector).on('click',function(){....
    reading the api always helps me : http://api.jquery.com/on/

  • #3
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the quick reply. I think that's where I'm confused, because I'm not trying to bind a click event to the element, rather I'm trying to attach the tinytabs component to the element. The tab control works great when attaching to static content, just not the new code I inject.
    I have read and researched this, but have only found references to click.

    I know I'm missing something here, but just can't find it.

    Thanks

  • #4
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    probably best to show some code in a new post then, sounds like something CF can help with

    i looked at tinytabs, looks to be a very simple tab system, but doesnt show any support for dynamic content. worst case scenario you can always rebind the tabs after your dynamic events occur that can be a pain.

  • #5
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think the rebind functionality is what I'm missing. Rather than go down that path, I think I'll look for a way to create the tabs statically, and only inject the remaning dynamic code as necessary.

    Thanks for helping me clarify!


  •  

    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
    •