Search code examples
jqueryloaddocumentready

execute .ready() function after .load


my problem is that i try to load the document.ready function after .load

first i used document ready on each site, but now i decided to load the content with .load in a wrapper, the site had document readys for some functions and now i want to execute them after .load is ready, now i tried this

first a page was like this

...
<script>

$(document).ready(function()
{
    $('.file').preimage();
});

</script>
...

now its the simple html and i tried this

...
    function showHint(str, dir)
    {
    $( "#wrapper" ).html( '<span id="loader"></span>' );
    $('#wrapper').load(str +'.php?' + $.param(dir),function(){

    $('.file').preimage();
...

in my index but it doenst work, whats wrong with my code?

sorry for my crappy english ... i hope it's not that hard to understand


Solution

  • At what point are you calling the function ? It should work like that:

    function showHint(str, dir) {
       $("#wrapper").html( '<span id="loader"></span>');
       $('#wrapper').load(str +'.php?' + $.param(dir), function() {
          $('.file').preimage();
       });
    }
    
    $(document).ready(function() {
        showHint('some-url', 'some-param');
    });