seth2958 seth2958 - 28 days ago 8
jQuery Question

Need to get dynamically created ID from jquery plugin Dyna Tabs

I am using a really nifty plugin call Dyna Tabs which is able to generate tabs dynamically, but I need to be able to get the ID of the newly created tab so that I can manipulate the content for that specific ID. Here is the function for how the tab is created:

tabID : 'addstatictab',
type : 'ajax',
url : 'ajaxcontent.html',
method : 'get',
dtype : 'html',
params : {},
tabTitle : 'New Ajax Tab'

Here is an example of the created tab, whose ID is "tabview_addstatictabbody4."

<div id="tabview_addstatictabbody4" class="unselected" style="display: block;"><p>This HTML content is loaded statically</p></div>

How do I get/refer to this dynamically created ID using jquery?

Answer Source

I'm guessing it appends the div to another element?

Well let's pretend the parent is:

<div id="tabs"></div>

You could then possibly do:

$('#tabs div:last')

to get the last div element within "tabs"

If you need to store the ID's for future reference:

var TabId = new Array();

And on each load:

TabId[$('#tabs div').length - 1] = $('#tabs div:last').attr('id')