Skip to content

Instantly share code, notes, and snippets.

Created September 5, 2013 17:54
Show Gist options
  • Save anonymous/6453705 to your computer and use it in GitHub Desktop.
Save anonymous/6453705 to your computer and use it in GitHub Desktop.
RequireJS with multiple functions - how to call a function. Getting "undefined is not a function" error
...
<script data-main="" src="libraries/require.js"></script>
<script type="text/javascript">
//function that get's called on body onload
define('loadPage', ['hideAllDivs'], function createLoadPage()
{
return function loadPage()
{
console.log("here");
hideAllDivs();
};
});
//hide all divs
define('hideAllDivs', [], function()
{
return function hideAllDivs()
{
console.log("hi");
};
});
require(['libraries/jquery-1.10.2.min', 'loadPage'], function(loadPage) {
$(function() {
loadPage(); //****Getting "undefined is not a function" at THIS line*******//
console.log("hello");
});
});
</script>
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment