This is a very strange thing. I have a custom.js file with functions and listeners needed in some views. The listeners work fine in the views as the custom.js in called in the header. But the functions do not seem to work. I get an error "Uncaught ReferenceError: someFunction is not defined". I checkedc and checked if the spelling of the function name is correct and that's not it, it seems. But I find it very strange as the javascript file is parsed correctly as the listeners work.
Please can somebody please help me here
custom.js
$(document).ready(function () {
var someFunction = function() {
//do something
}
});
Header of default.ctp
<script src="/js/custom.js"></script>
Call to a function in a view
<script type="text/javascript">
someFunction();
</script>
Nothing seems wrong to me. Looks like a straight forward thing. So wondering if this is a typical cakePHP thing