Last active
August 29, 2015 14:00
-
-
Save Gubolin/11036000 to your computer and use it in GitHub Desktop.
jQuery Mobile add tab dynamically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div data-role="tabs" id="tabs"> | |
<div data-role="listview" id="tabnav"> | |
<ul> | |
<li><a href="#test">Test</a></li> | |
</ul> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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