06_load-remote-tab-only-once.patch

Marius BALTEANU, 2017-05-01 15:59

Download (1.57 KB)

View differences:

public/javascripts/application.js
369 369
  return false;
370 370
}
371 371

  
372
function getRemoteTab(name, remote_url, url) {
373
  $('#tab-content-' + name).parent().find('.tab-content').hide();
374
  $('#tab-content-' + name).parent().find('div.tabs a').removeClass('selected');
375
  $('#tab-' + name).addClass('selected')
372
function getRemoteTab(name, remote_url, url, load_always = false) {
373
  var tab_content = $('#tab-content-' + name);
376 374

  
377
  replaceInHistory(url)
375
  tab_content.parent().find('.tab-content').hide();
376
  tab_content.parent().find('div.tabs a').removeClass('selected');
377
  $('#tab-' + name).addClass('selected');
378 378

  
379
  $.ajax({
380
    url: remote_url,
381
    type: 'get',
382
    success: function(data){
383
      $('#tab-content-' + name).html(data).show();
384
    }
385
  });
379
  replaceInHistory(url);
386 380

  
381
  if (tab_content.children().length == 0 && load_always == false) {
382
    $.ajax({
383
      url: remote_url,
384
      type: 'get',
385
      success: function(data){
386
        tab_content.html(data)
387
      }
388
    });
389
  }
390

  
391
  tab_content.show();
387 392
  return false;
388 393
}
389 394

  
390
-