<% tabs_list = active_secondary_tabs_list(current_app_id, @current_tab_id, custom_secondary_tabs(@current_tab_id)).reject{ |tab| tab.first==@current_tab_id }
   tabs_list.each do |tab| %>
     <article class="tab-pane" id="<%= tab[0] %>"></article>
<%=  javascript_on_load do %>
     $('a[href="#<%= tab[0] %>"]').on('shown.bs.tab', function (e) {
     if($('div.tab-content > #<%= tab[0] %>').html().length==0) {
<%       url = tab[2]
         if url.start_with? '/' %>
       $("#tab-content-loading").show();
       $.ajax({url: '<%= url %>', type: 'GET', dataType: 'script',
       success: function (response) {
       $("#tab-content-loading").hide();
       },
       error: function (response) {
       $("#tab-content-loading").hide();
       }
       });
     <%       else %>
           window.location.href = "<%= url %>";
<%       end %>
     }
     });
<%   end %>
<% end %>

<% tabs_list = active_secondary_tabs_list(current_app_id, @current_tab_id, custom_secondary_tabs(@current_tab_id)).reject{ |tab| tab.first==@current_tab_id }
   tabs_list.each do |tab| %>
     <article class="tab-pane" id="<%= tab[0] %>"></article>
<%=  javascript_on_load do %>
     $('a[href="#<%= tab[0] %>"]').on('shown.bs.tab', function (e) {
     if($('div.tab-content > #<%= tab[0] %>').html().length==0) {
<%       url = tab[2]
         if url.start_with? '/' %>
       var elem = $(this);
       var loading_markup = "<span class='tab-content-loading'></span>";
       elem.after(loading_markup);
       $.ajax({url: '<%= url %>', type: 'GET', dataType: 'script',
       success: function (response) {
       elem.next('span.tab-content-loading').remove();
       },
       error: function (response) {
       elem.next('span.tab-content-loading').remove();
       }
       });
     <%       else %>
           window.location.href = "<%= url %>";
<%       end %>
     }
     });
<%   end %>
<% end %>

Add loading actions for ajax call
Add loading actions for ajax call

Added code to call the loading icon when the tab content is being pulled
from the ajax call, it now displays the gif in the same tab to make it
look nicer.
