0

My code looks like this:

function submitHandler($link, $modal, close) {
    var ...
    var onDone = function (json, textStatus, XMLHttpRequest) {
     ...
    }
    var onFail = function (XMLHttpRequest, textStatus, errorThrown) {
     ...
    }
    var successModal = function (json) {
    ...
    }
    var failModal = function (json) {
       ...
    }
    if (!$form.get(0).checkValidity || $form.get(0).checkValidity()) {
    ...
        $.ajax({
        ....
            .done(onDone)
            .fail(onFail);
    }
}

All my related functions are together in the same file. I previously had the functions in different files but then I found out that it seemed better if they were in one file so they could share the same variables (at the top of the file). Is this the coding practice most people use or do they put each javascript function in its own file? Is there any way to include contents of a file inside of another ?

Samantha J T Star
  • 30,952
  • 84
  • 245
  • 427
  • 1
    Similar question [here](http://stackoverflow.com/q/950087/944681) – Michal Klouda Sep 18 '12 at 07:21
  • This is not similar as that question is asking from a performance point of view. I mimify and join all my js files so they end up as one file. What I am asking is from a developer/maintenace point of view what do people do. Many files, one file. Can files be included. Thanks. – Samantha J T Star Sep 18 '12 at 08:55

0 Answers0