【问题标题】:Missing: after property list缺失:在属性列表之后
【发布时间】:2013-02-09 11:56:17
【问题描述】:

这段代码给了我这个错误:missing : after property list 错误注释在哪里。

$("#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'];?>"
});

我想知道如何解决这个错误,我是否通过查看以下文档正确实现了 pauseOthers 函数:DOCUMENTATION

【问题讨论】:

    标签: php javascript jquery


    【解决方案1】:

    您正在拨打这个电话:

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

    在声明一个对象字面量的中间:

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

    这只是无效的 JavaScript 语法。也许您打算将.bind() 调用放在ready 回调中?

     $("#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'];?>"
    });
    

    【讨论】:

    • 如果您不介意,请问您以前用过jplayer吗?我想实现这个jplayer.org/latest/demo-03 但不知道该怎么做。目前,如果我有多个 jplayer 音频播放器,如果我点击一个,它会在所有播放器中播放音频,而不是在它自己的播放器中播放。这就是我正在努力实现但正在苦苦挣扎的目标
    • 不,我没有使用过 jPlayer。打开一个新问题,下次不要费心显示 PHP - 请显示生成的 JavaScript,因为那是浏览器看到的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-13
    • 2017-03-07
    相关资源
    最近更新 更多