2011-06-30 9 views
0

私のサイトには、Chtml :: ajaxButtonを含むiframeがあります。私はこの問題に関する多くの記事を見つけましたが、解決策を見つけることができませんでした。IFrame内でajaxを使用する

私が強調しておきたいことは、このiframeがホストページとは異なるドメインにデータを送信するために使用されていないことです。

view.php

 <div style="height: 385px; width: 350px; overflow: hidden"> 
      <?php $url = "displayMessages?league_id=".$model->id; ?> 
      <iframe src="<?php print $url?>" width="350" height="385"> 
      </iframe> 
     </div> 

LeaguesController.php

public function actionDisplayMessages() 
{ 
    if(isset($_GET['league_id'])){ 
     $selectedLeague = $_GET['league_id']; 
     $league = LigasDeAmigos::model()->findByPk((int)$selectedLeague); 
     $user = (int)Yii::app()->user->id; 
     $this->renderPartial('leagueWallMessages', array(
                'model'=>$league, 
                'messages'=>$league->messages, 
                'user'=>$user, 
     )); 
    }  
} 

LeagueWallMessages.php

<?php 
    echo CHtml::ajaxButton(
     "Compartir", CController::createUrl('leagues/insertComment', 
    array(
     'league_id'=>$model->id)), 
     array(
      'success' => "js: function(){ alert('Success!!'); }", 
      'type' => 'post', 
     ), 
     array(
      'id'=>'idButtonShare', 
      'style'=>'width:70px;height:40px; align:right;' 
     ) 
    ); 
?> 

LeagueWallMessages.phpのこのボタンは、クリックされてもアクションを開始しません。この問題の原因は何ですか?

答えて

1

私はボタンをフォーム定義の中に入れることを忘れていました。フォーム内にボタンやその他のコンテンツを配置し、ボタンをajaxSubmitButtonに変更しました。

関連する問題