2015-09-07 64 views
0

我在彈出視圖中使用了JQRelcopy擴展。當我使用render()時,擴展工作正常,但每次打開顏色框時,它都會將舊值傳遞給控制器​​。 如果我使用renderPartial(),當我打開顏色框時,每次向控制器發佈新值,但擴展名(JQRelcopy)不克隆字段。JQRelcopy在renderPartial中不工作

這是我在視圖中使用extenion:

Yii::import('ext.jqrelcopy.JQRelcopy'); 

$this->widget('ext.jqrelcopy.JQRelcopy',array(
    'id' => 'copylink', 
    'removeText' => '<i class="icon-remove" style="margin-left: 1px;"></i>', 
    'removeHtmlOptions' => array('style'=>'color:red; margin-left: 45px'), 
    'jsAfterCloneComplete' => 'initializeTimePicker()', 
    'jsAfterNewId' => JQRelcopy::afterNewIdDatePicker(Util::getCustomDatePicker($briefingEquipment, 0, $minDate, $maxDate)), 

    'options' => array(
     'copyClass' => 'copy', 
     'limit' => 10, 
     'clearInputs' => true, 
     'excludeSelector' => '.skipcopy', 
    ) 
)); 

這是我的控制器代碼:

public function actionShowEquipment() 
{ 
    $this->layout = "//layouts/popup"; 

    $equipmentConflicts = ''; 
    $briefingId = $_POST['briefingId']; 
    $briefingDate = $_POST['briefingDate']; 
    $briefingEndDate = isset($_POST['briefingEndDate']) ? $_POST['briefingEndDate'] : ''; 
    $serializeBriefingEquipments = isset($_POST['briefingEquipments']) ? $_POST['briefingEquipments'] : ''; 

    $equipment = CHtml::listData(Equipment::model()->findAll(), 'id', 'name'); 
    $briefingCenter = BriefingCenter::model()->findByPk(Yii::app()->user->currentBriefingCenterId); 

    if ($briefingId) { 
    $briefingEquipmentArr = BriefingEquipment::model()->findAll('briefing_id = :bId', array(':bId' => $briefingId)); 

     if (!$briefingEquipmentArr) { 
      $briefingEquipmentArr[] = new BriefingEquipment(); 
     } 
    } else if ($serializeBriefingEquipments) { 
     $serializeBriefingEquipments = unserialize($serializeBriefingEquipments); 
    } 

    $briefing = Briefing::model()->findByPk($briefingId); 

    if (!empty($briefing->scheduled_date) && !empty($briefing->scheduled_end_date)) { 
     $minDate = $briefing->scheduled_date; 
     $maxDate = $briefing->scheduled_end_date; 
    } else { 
     $minDate = $briefingDate; 
     $maxDate = $briefingEndDate; 
    } 

    echo $this->renderPartial('edit/equipment', array(
     'briefing' => array(
      'briefingId' => $briefingId, 
      'briefingDate' => $briefingDate, 
      'briefingEndDate' => $briefingEndDate, 
     ), 
     'minDate' => strtotime($minDate), 
     'maxDate' => strtotime($maxDate), 
     'briefingEquipmentArr' => $briefingEquipmentArr, 
     'equipments' => $equipment, 
     'briefingCenter' => $briefingCenter, 
     'serializeBriefingEquipments' => $serializeBriefingEquipments, 
     'dateFormat' => Yii::app()->user->currentBriefingCenterDateFormat, 
    )); 
} 

回答

0

的問題是因爲渲染和的RenderPartial,我用渲染和擴展工作非常好。 以下是我採用了Stackoverflow的render和renderPartial之間的區別。

render()通常用於呈現與用戶在應用程序中看到的「頁面」相對應的視圖。它首先呈現您指定的視圖,然後呈現當前控制器操作的佈局(如果適用),將第一個呈現的結果放入佈局中。然後執行輸出處理(此時意味着自動插入任何必要的標籤並更新動態內容)並最終輸出結果。

renderPartial()通常用於呈現頁面的「塊」。與render()的主要區別在於,此方法不會將渲染的結果放置在佈局中。默認情況下,它也不執行輸出處理,但可以使用$ processOutput參數覆蓋此行爲。