1

I am working as a trainee on a JavaScript project but the project is complex and i am a newbie to javascript.
I want to find the call to this method/closure (i am not sure if its method or closure) but i could not find it i searched entire project folder with grep but no call found. Please help me in finding this:

        createTabs : function(arr) {
                // Close the user link menu
                $("#closeMenu").trigger('click');

                if(arr) {
                    var module_url = kmc.vars.service_url + '/index.php/kmc/kmc4',
                        arr_len = arr.length,
                        tabs_html = '',
                        tab_class;
                    for( var i = 0; i < arr_len; i++ ) {
                        tab_class = (arr[i].type == "action") ? 'class="menu" ' : '';
                        tabs_html += '<li><a id="'+ arr[i].module_name +'" ' + tab_class + ' rel="'+ arr[i].subtab +'" href="'+ module_url + '#' + arr[i].module_name +'|'+ arr[i].subtab +'"><span>' + arr[i].display_name + '</span></a></li>';
                    }
    }

}

basically i am searching for arr so that i can modify it and i searched entire project for a call to createTabs. please help me and tell me if i am doing something wrong.

Sachin Verma
  • 3,712
  • 10
  • 41
  • 74

1 Answers1

0

There shouldn't be any function createTabs. For this function to exist the syntax should have been like this:

createTabs = function(arr) {
    if(arr) {
        alert(arr);
    }
}
alert(createTabs(true));

What you have there is only a part of a function. Take for example the basic JQuery Dialog:

           $("#dialog").dialog({
                autoOpen: false,
                open: function() {
                    alert('oppened!!!');
                }
            });

When you call $("#dialog").dialog("open"); the anonymous function assigned to the open attribute will be called upon opening of the dialog.

The same applies in your case. There should be some other code/function surrounding the given code you have provided.

For more info on javascript functions syntax visit Explain the encapsulated anonymous function syntax or Javascript Function Definition Syntax

Community
  • 1
  • 1
MaVRoSCy
  • 17,747
  • 15
  • 82
  • 125