Hello all,
I am testing new mobile app project and fetching data from the server by
getJSON(); and the list take some time to be loaded. what i want is loading dialog to appear in the center of the list container. I tried
$.mobile.loading but it appears in the middle of the page not inside the list container !
here is my code
- <body>
-
- <div id="home-page" data-role="page">
- <div id="home-header" data-role="header">
- <h1><i class="icon-home"></i> Header</h1>
- </div><!-- /#header -->
-
- <div id="home-content" data-role="content">
- <ul id="category_list" data-filter="true" data-theme= "a" data-inset="true"> </ul>
- </div>
-
-
- <div id="footer" data-role="footer">
- <h1><i class="icon-coffee"></i> 2014 - Touch Marketing & Advertising</h1>
- </div><!-- /#footer -->
- </div>
-
- </body>
here is the script
- $.ajax({
-
- url: 'http://api.ihackernews.com/page?count=2&format=jsonp',
- crossDomain: true,
- dataType:'jsonp',
- type:'GET',
- cache: false,
-
- success: function(data){
- var loading = $.mobile.loading('show');
- $('#category_list').append(loading);
-
-
- $(data.items).each(function(index, val) {
-
- category = '<li><a href="posts.html" onclick="postList('+val.id+', '+val.post_count+')"> \
- '+val.title+' \
- </a></li>';
-
- $('#category_list').append(category);
-
-
- });
-
- }
-
- });