Create Jquery Mobile Navbar dynamically from JSON data

I’m trying to dynamically create a navbar from data i fetch from a web api serving json data. Here’s the code:
If i use:

directly in html code works fine, but this is not what im looking for. I want to be able to create the list elements from the data in the like the code in gist show. Anyone could point me in the right direction?

Once you have concocted your HTML for the navbar widget, you simply call .trigger('create')
on the widget:

var myNavbar = $('');

Here is a demo:

This will trigger jQuery Mobile to initialize the widget.

For Example:

var url = "";var jsonresults;
    var output = [];
    $.each(jsonresults, function(i,v){
  • ' + jsonresults[i].name + '
  • '); }); $('#main-content').append('
    ' + output.join('') + '
    ').trigger('create'); });

    Notice how I concocted the HTML, and used the .append()

    Hello, buddy!责编内容来自:Hello, buddy! (源链) | 更多关于

    本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
    酷辣虫 » 移动开发 » Create Jquery Mobile Navbar dynamically from JSON data

    喜欢 (0)or分享给?

    专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

    使用声明 | 英豪名录