2013-07-09 38 views
1

我使用多個按鈕(動態),打開一個單個的div:

通行證值對話框模態

<div class="dialog" title="Player"> 
    <p>YouTube Player here</p> 
</div> 



,並在標頭我使用:

<script> 
    $(function() { 
     $(".dialog").dialog({ 
      autoOpen: false, 
      show: { 
       effect: "blind", 
       duration: 1000 
      }, 
      hide: { 
       effect: "blind", 
       duration: 1000 
      } 
     }); 

     $(".opener").click(function() { 
      $(".dialog").dialog("open"); 
     }); 
    }); 
</script> 



我得到的按鈕像這樣使用:

foreach ($ytObject->RKT_requestResult->entry as $video) { 
    return = $ytObject->parseVideoRow($video); 
    $delimiter = "**"; 
    $VideoContent = explode($delimiter, $return); 
    if ($count % 2 == 0) { 
     echo "<div class=\"ResultEven\">"; 
     echo "<button class=\"opener btn\" class=\"btn\">Play</button>&nbsp;"; 
     echo "<a href = \"" . $VideoContent['0'] . "\" class=\"btn\">Download</a>&nbsp;"; 
     echo $VideoContent['6']; 
     echo "</div>"; 
    } else { 
     echo "<div class=\"ResultOdd\">"; 
     echo "<button class=\"opener btn\" class=\"btn\">Play</button>&nbsp;"; 
     echo "<a href = \"" . $VideoContent['0'] . "\" class=\"btn\">Download</a>&nbsp;"; 
     echo $VideoContent['6']; 
     echo "</div>"; 
    } 
    $count++; 
} 




我希望得到儘可能的<div class="dialog" title="player">所以彈出內容,我可以直接把YouTube的視頻模態的$VideoContent['0']值。

回答

2

使用下面的代碼來獲取值:

$(".opener").click(function() { 
    var video = $(this).siblings("a").attr("href"); 
    alert(video); //here video will have the value of $VideoContent['0'] 
    $(".dialog").dialog("open"); 
}); 
+1

謝謝你的哥們。我已經完成了^ _ ^ – programmer

1

我都做到了。我所使用的功能是:

<script> 
    $(function() { 
     $(".dialog").dialog({ 
      width: 450, 
      autoOpen: false, 
      show: { 
       effect: "blind", 
       duration: 1000 
      }, 
      hide: { 
       effect: "blind", 
       duration: 1000 
      } 
     }); 
     $(".opener").click(function() { 
      var video = $(this).siblings("a").attr("href"); 
      var VideoId = video.replace('http://www.youtube.com/watch?v=', ''); 
      var VideoId = VideoId.replace('&feature=youtube_gdata', ''); 
      var youtube = "<embed width=\"420\" height=\"345\" src=\"http://www.youtube.com/v/" + VideoId + "\" type=\"application/x-shockwave-flash\"> </embed>"; 
      $(".dialog").dialog("open").html(youtube); 
     }); 
    }); 
</script> 

和鏈接/按鈕來打開它

<button class="opener btn" class="btn"><img src="img/Play-icon.png" alt="play" />&nbsp;Play</button> 

echo "<a href = \"" . $VideoContent['0'] . "\" class=\"\"></a>&nbsp;"; 

可能有點傻或棘手的:P但是正常工作!^_^

其實按鈕進入循環。所以,我已經使用按鈕來顯示模式和空白的href來獲取值。而已。 :)