Here is my HTML/JavaScript:
Try this:
$(function() { window.foo = function () { alert('bar'); } });
Basically, you need to expose the function to global scope.