0

I have a HTML-page where I include all of my js.files in the head

<head>
    <link rel="stylesheet" type="text/css" href="css/styles.css">   
    <link rel="stylesheet" href="css/addtab.css">
            //some more
    <link rel="stylesheet" href="css/tab_menu.css">

    <script src="js/addtab.js"></script>
    //some more
    <script src="js/tab_menu.js"></script>
</head>

and in the addtab.js I declare a function, I want to use there and in the tab_menu.js:

addtab.js:

function addTab (a=null, b=null) {
     //doing Stuff 
}

tab_menu.js:

;$(function() {

    tabs.delegate( "div.copier", "click", function() {
        //doing stuff

        addtab(title, descryption);

        //doing stuff
    }); 
});

but I get that:

ReferenceError: addtab is not defined

Edit: Okay.. it was just a typo, but thanks to the others that you pointed out a mistake I haven't noticed yet^^ So that I can solve them at a stroke...

4
  • 1
    @SridharR — That can't be the problem. It is complaining about addtab not $. Commented Apr 17, 2014 at 9:39
  • 1
    function addTab (a=null, b=null) { change it to function addTab (a, b) Commented Apr 17, 2014 at 9:40
  • Default parameters are supported by FF only. Commented Apr 17, 2014 at 9:41
  • @Teemu I'm programming and testing first in FF, so that's why he doesn't complaint about that... Commented Apr 17, 2014 at 10:14

2 Answers 2

5

You define addTab but call addtab. Javascript function names are case sensitive.

Sign up to request clarification or add additional context in comments.

Comments

2

function addTab (a=null, b=null) { is not valid JS.

You can't assign values to augments in the function declaration.

It should be:

function addTab(a, b) {

You should have got an Uncaught SyntaxError: Unexpected token = error before the error you reported.


Then you try to call addtab when the function is called addTab. JavaScript identifiers are case sensitive.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.