私のプログラムの目的は、JQuery でリンクをクリックしてカラーボックスを開くことです。
コードは次のとおりです。
<a href="<?= $html->url(array('controller' => 'competitions', 'action' => 'index')) ?>" class="game-popup">
<?= $this->Html->image('image-link.jpg') ?>
</a>
<script type="text/javascript">
$(document).ready(function(){
$('.game-popup').colorbox({'iframe':true, 'width':'690px', 'height':'670px'});
});
</script>
このコードは完全に機能します。
別の理由で、クリックせずに特別な条件でカラーボックスを自動的に開く必要があります。以下のコードを試しましたが、コントローラーにアクセスできません。
<a href="<?= $html->url(array('controller' => 'competitions', 'action' => 'index')) ?>" class="game-popup">
<?= $this->Html->image('competition-galaxy-s3.jpg') ?>
</a>
<script type="text/javascript">
$(document).ready(function(){
$.colorbox({'iframe':true, 'width':'690px', 'height':'670px'});
document.location.href="/ArgusDuMobile/competitions/index";
});
</script>
ページを更新すると、カラーボックスが開かれていますが、そのコンテンツがないため、コード行は$.colorbox
良いようです。コントローラーとのリンクを行うために、次のコード行を試しましたdocument
が、ビューの正しいコンテンツを別のページで開きますが、カラーボックスには開きません。
誰でも私を助けることができますか?ご回答ありがとうございます。