title: How to access defined functions using RequireJS
body: <p>I am working with Chris Imrie's iteration of RequireJS for ExpressionEngine making all my fieldtypes compatible. One thing I don't understand is how to call the functions that are defined in RequireJS.</p>
  
  <p><a href="https://github.com/ckimrie/RequireJS-for-EE" rel="nofollow">https://github.com/ckimrie/RequireJS-for-EE</a></p>
  
  <p>Here is a basic example of what I am trying to do...</p>
  
  <pre><code>var loadImage = function() {
      console.log('loaded');
  }
  
  define(function () {
      return loadImage;
  });
  </code></pre>
  
  <p>How do I actually access the loadImage function? My code worked 100%, but when I started using RequireJS, the libraries behave differently. Below is a snippet from a library I am using, it's completely forked for RequireJS. If I delete the fork and use the standard jQuery call, it works without issue (even with RequireJS loading all the scripts).</p>
  
  <p>Does not work:</p>
  
  <pre><code>if (typeof define === 'function' &amp;&amp; define.amd) {
      define(function () {
          return loadImage;
      });
  } else {
      $.loadImage = loadImage;
  }
  </code></pre>
  
  <p>Does Work</p>
  
  <pre><code>$.loadImage = loadImage;
  </code></pre>
  
  <p>Why would jQuery libraries fork the code like this? I am concerned I am overlooking something simple, but given the context that all this code is with ExpressionEngine Fieldtypes, I don't have a problem altering the libraries.</p>