javascript - Accessing Code inside $(function () { ... }) -


i have .net web control includes javascript structured this:

<script type="text/javascript">      function dosomethingimportant() {         // important here...     }      $(function () {          // bunch of javascript/jquery code here...      });  </script> 

the dosomethingimportant() function placed outside of $(function() { ... }) block can called javascript on page hosts web control.

but function able access code within $(function() { ... }) block. possible? there better way structure this?

if add code on window object in jquery function can call outer function.

e.g.

<script type="text/javascript">      function dosomethingimportant() {         // important here...        window.myfunc();     }      $(function () {          // bunch of javascript/jquery code here...        window.myfunc = function(){       }      });  </script> 

Comments