I have a file- "Site.js" with the following method:
function Init() {
$(document).ready(function() {
//some init actions here
});
}
function jQuery.fn.DivToggle(div) {
$(div).toggle('fast');
//some other animation code here
}
in my Index.cshtml file (I'm using asp.net mvc), I have this:
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Site.js")" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
$(function () {
Init();
});
</script>
</body>
</html>
I get this error when I run the project: "Microsoft JScript runtime error: 'Init' is undefined"
Any idea what I'm doing wrong?
$(function () { all functions here });tag? if so, theinit()function will be private an unable to call it from outside of Site.jsfunction jQuery.fn.DivToggle(){}<= you can't actually do that. It should bejQuery.fn.DivToggle=function(){}