2

This code is giving me this error: missing : after property list where error comment is.

$("#jquery_jplayer_1-<?php echo $key.'-'.$j; ?>").jPlayer({
     ready: function () {
          $(this).jPlayer("setMedia", {
               <?php echo $info['extension'];?>: "<?php echo "AudioFiles/".$a; ?>"
          });
     },
     $(this).bind($.jPlayer.event.play, function() { //ERROR HERE
          $(this).jPlayer("pauseOthers");
     },
     solution:"flash,html",
     swfPath: "jquery",
     supplied: "<?php echo $info['extension'];?>"
});

I want to know how to fix this error and am I implementing the pauseOthers function correctly by looking at this documentation: DOCUMENTATION

4

1 回答 1

1

You're putting this call:

$(this).bind($.jPlayer.event.play, function() { //ERROR HERE
  $(this).jPlayer("pauseOthers");
}

Smack in the middle of declaring an object literal:

{
    ready: function () {
      $(this).jPlayer("setMedia", {
        <?php echo $info['extension'];?>: "<?php echo "AudioFiles/".$a; ?>"
      });
    },
    solution:"flash,html",
    swfPath: "jquery",
    supplied: "<?php echo $info['extension'];?>"
}

which is simply invalid JavaScript syntax. Perhaps you meant to put the .bind() call inside of the ready callback?

 $("#jquery_jplayer_1-<?php echo $key.'-'.$j; ?>").jPlayer({
    ready: function () {
      $(this).jPlayer("setMedia", {
        <?php echo $info['extension'];?>: "<?php echo "AudioFiles/".$a; ?>"
      });
      $(this).bind($.jPlayer.event.play, function() { 
          $(this).jPlayer("pauseOthers");
        });
    },
    solution:"flash,html",
    swfPath: "jquery",
    supplied: "<?php echo $info['extension'];?>"
});
于 2013-02-09T03:25:24.023 回答