Global javascript function
<p>I have a method which detects broken links with a .imageclass class like so:</p>

<pre><code>$('.imageclass').one('error', function() {
    alert('broke');
});
</code></pre>

<p>That I want to be used in several files.<br>  How would I go about doing this?<br>
I've tried using a separate js file with:</p>

<pre><code>function checkErrors(){
    $('.imageclass').one('error', function() {
        alert('broke');
    });

}
</code></pre>

<p>and then calling this on each of the files:</p>

<pre><code>$(document).ready(function() {
    checkErrors();
});
</code></pre>

<p>But it doesn't seem to work. <br>
The method is called however there is no alert when it spots a broken link. <br>
If I use:</p>

<pre><code>$(document).ready(function() {
    $('.imageclass').one('error', function() {
        alert('broke');
    });
});
</code></pre>

<p>The alert occurs.</p>
