How to transfer a variable from one .js file to another .js?

I have a symfony application with a menu that creates eyelashes and uses the .js file to load into a div that ulr points to each menu item using the load () method. This .js is a variable that acts against the link to each tab created. This idea can be seen in this example:

http://jsfiddle.net/JMMS_85/o7610t24/

$("#tabs-"+tabCounter).load($(this).attr('href'));

The URL that loads in the div has other links, so I created another .js file to block the original link to "preventDefault ()", and I need to reload these links in it before the div, that is, display the URL of the new the links are in the same div, so I have to use the variable counter counter.js file on it to find out what the actual div has selected.

file1.js

 $(document).ready(function () {
$("#tabs").tabs();
   var tabCounter = 1;
   var cont =1;

        //Code creating the tabs omitted
 $(".container div a").on("click",function(event) {
    event.preventDefault(); 

        tabTitle = $(this).attr("title"),
        addTab();
        $("#tabs-"+tabCounter).load($(this).attr('href'));
        tabCounter++;
        $("#tabs").tabs({active: $('.ui-tabs-nav li:last').index()});
  });
 });

file2.js

$(document).ready(function () {

       $("a").click( function(event)
        {
        event.preventDefault();            

        $("#tabs-"+tabCounter).load(this.href);
    }); 

, - .js .

+4
2

DOM, jquery

:

$('#tabs').data('counter', 1);

var tabCounter = $('#tabs').data('counter');

var tabCounter = $('#tabs').data('counter');
$('#tabs').data('counter', ++tabCounter);

Demo

http://jsfiddle.net/o7610t24/3/

+1

All Articles