Loading ...
Sorry, an error occurred while loading the content.

Re: best practice for "making functions known" from other files

Expand Messages
  • Douglas Crockford
    ... I think you meant either var Common = { functionX: function () {}, myajaxcall: function () {} }; or var Common = function () { return { functionX: function
    Message 1 of 5 , Aug 27, 2008
    • 0 Attachment
      > I had a hellava time figuring this one out. What I did was throw all
      > of my common functions into a namespace (eg. Common). So for example:
      >
      > Common = function () {
      > functionX = function () {
      > ...
      > },
      >
      > myajaxcall = function () {
      > ...
      > }
      > }();
      >
      > Then you can just refer to these functions as Common.myajaxcall(). On
      > your other pages, you just put on the top /*global Common */ and that
      > will tell jslint that Common is an accepted global object.

      I think you meant either

      var Common = {
      functionX: function () {},
      myajaxcall: function () {}
      };

      or

      var Common = function () {
      return {
      functionX: function () {},
      myajaxcall: function () {}
      };
      }();
    Your message has been successfully submitted and would be delivered to recipients shortly.