Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to dynamically add a navbar to a jQuery Mobile application

How can I dynamically add a navbar to my jquery mobile application? From javascript I want to be able to add the navbar elements to the dom and then have them parsed.

like image 300
Boushley Avatar asked Jul 14 '11 03:07

Boushley


2 Answers

I found that I could add the element to the DOM however I wanted, and then call .navbar() on the element and it would perform the navbar parsing.

For instance I could use

var myNavBar = $('div', {
    'data-role':'navbar',
    'html':'<ul><li><a id="some">First</a></li></ul>'
}).appendTo(myPage).navbar();
like image 165
Boushley Avatar answered Nov 01 '22 10:11

Boushley


Use this code after appending HTML code using DOM:

$("div[data-role='navbar']").navbar();

like image 28
Akila Darshana Avatar answered Nov 01 '22 11:11

Akila Darshana