Skip to content

Instantly share code, notes, and snippets.

@Gubolin
Last active August 29, 2015 14:00
Show Gist options
  • Save Gubolin/11036000 to your computer and use it in GitHub Desktop.
Save Gubolin/11036000 to your computer and use it in GitHub Desktop.
jQuery Mobile add tab dynamically
<div data-role="tabs" id="tabs">
<div data-role="listview" id="tabnav">
<ul>
<li><a href="#test">Test</a></li>
</ul>
</div>
</div>
function addTab(name, content){
$('#tabnav ul').append('<li><a href="#' + name + '">' + name + '</a></li>');
$('#tabs').append('<div id="' + name + '">' + content + '</div>');
$('#tabs').tabs('refresh');
}
addTab('foo', 'bar');
$('#tabnav').navbar();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment