0

Possible Duplicate:
How to have Ajax spinner show on specific page?

I have this nav menu with 2 tabs:

<div id="user_menu">
 <ul class="nav nav-tabs">
  <li class="active"><%= link_to "Group1", group1_friends_path(@user), :remote => true %></li>
  <li><%= link_to "Group2", group2_friends_path(@user), :remote => true %></li>
 </ul>
</div>

I've managed to let Ajax render certain partials. Now, when I click on the tabs the partials loads in my target placeholder div.

tab.js: which I placed in assest/javascripts/

$(function() {
    $('#user_menu a').click(function (e) {
        $('ul.nav-tabs li.active').removeClass('active')
        $(this).parent('li').addClass('active')
        $("#friends-data").fadeOut(function(){
            $("#loading-indicator").fadeIn();
        });
    });
});

I don't like to show all the content all the same time and let the user wait for all the http request to render. I would like to show a loading bar and when all the http request is finished, hide the loadingbar and show the content.

Right know is more theatrical then functional. Any help, example would be appreciated.

Community
  • 1
  • 1
  • 1
    Look at the answer I gave to this other answer. Seems like it's what you are looking for. http://stackoverflow.com/questions/11063356/how-to-have-ajax-spinner-show-on-specific-page/11064973 – Ashitaka Jul 31 '12 at 17:18
  • @Ashitaka thansk for the tip, but what I really want, is that ajax checks that every http request is finished then show the content and in the mean time show the loadingbar.. –  Aug 01 '12 at 00:31
  • So... You don't want the user to click those remote links? You just want the page to render with some loading bars and then in the background load the partials, without any user interaction? – Ashitaka Aug 01 '12 at 01:56
  • @Ashitaka What I mean is that if you want the best user experience one must have both. –  Aug 01 '12 at 02:14
  • When a user clicks those links, isn't the content loaded automatically already? – Ashitaka Aug 01 '12 at 02:19
  • @Ashitaka I dont think you really understand my question and what I want to do. –  Aug 01 '12 at 14:42
  • I agree. But I assure you, the problem isn't on my end. – Ashitaka Aug 01 '12 at 19:57

0 Answers0