This is my code:
In JSFile.js:
alert('hello');
$('#mydiv').change(function(){
alert("i'm here");
})
In a script in html file:
<asset:javascript src="JSFile.js"/>
<script>
$(document).ready(function(){
$('#mydiv').trigger('change');
});
</script>
The JS file gets imported correctly cause i see the 'hello' alert when i load the html file, but the 'i'm here' alert never pops up. If i copy the code from the js file and paste it below the document ready, the alert pops up.
Does anybody know how to make it work the way I want? Thanks.