I have good dialogs defined as such in jQuery:
<script type="text/javascript"> $(document).ready(function() { $( "#someDialog" ).dialog({ autoOpen: false, model: true, buttons: { "Do Something": function() { var cleanInput = sanitizeInput(input); </script>
Somewhere on a non-dialog page, I have an element that calls a function with a parameter:
<a href="#" onclick="doSomething('wendy');">Wendy stats</a>
And the related JavaScript:
<script type="text/javascript"> function doSomething(input) { var cleanInput = sanitizeInput(input); </script>
I would like to reuse the sanitizeInput () function for this function. However, outside the scope of the document.ready function, the dialog does not work. Enabling the doSomething () function inside the document.ready function also violates it. So where can I put the sanitizeInput () function so that both can use it?
Thanks.
source share