1

I'm hoping this makes sense. When a user clicks on a post title I'm launching a modal overlay via fancybox, and feeding the associated post content via ajax. However I have a javascript call function that I need to run that is from the post that isn't running when the content is pulled. I have a guess the it has something to do with $(document).ready(function() Any ideas? How to I load this function after the modal overlay has been triggered?

<script type="text/javascript">
$(document).ready(function(){
  $("#jquery_jplayer_1").jPlayer({
    ready: function () {
      $(this).jPlayer("setMedia", {
        m4v: "http://www.jplayer.org/video/m4v/Big_Buck_Bunny_Trailer_480x270_h264aac.m4v",
        ogv: "http://www.jplayer.org/video/ogv/Big_Buck_Bunny_Trailer_480x270.ogv",
        poster: "http://www.jplayer.org/video/poster/Big_Buck_Bunny_Trailer_480x270.png"
      });
    },
    swfPath: "/js",
    supplied: "m4v, ogv",
                        size: {
                     width: "850px",
                     height: "438px"
                }
  });
});
</script>

1 Answer 1

1

You need to apply any javascript after the content is loaded. See the Callbacks tab in documentation.

$(".fancybox").fancybox({
    afterLoad: function(current, previous){
        // initialize your js stuff  
    }
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.