I have a php document in which I add 'chapters' (jquery tabs) in two ways:

1. When a new chapter is created, it will be added to the list, and to the database, using javascript and Ajax. As you see, I already have a tabTemplate which is used for that.

```
li = $( tabTemplate.replace( /#\{href\}/g, "#tabs-" + id ).replace( /#\{label\}/g, label ).replace(/#\{chapid\}/g, id) );

tabs.find( ".ui-tabs-nav" ).append( li );

```
2. When tabs are initialized from the database, php and mysql will add the chapters to the list:

```
while($chaprow = mysql_fetch_array( $chapters )) 
{
  echo '<li><a href="#tabs-'.$chaprow['id'].'">'.$chaprow['name'].'</a><a href="#" onclick="deleteChapter('.$chaprow['id'].');return false;">D</a></li>';
}

```

How can I use the template I created in Javascript in the initialization of my database chapters?