当颜色框第二次打开时,使用render()值不会更新

时间:2015-09-08 05:36:20

标签: php jquery yii

我使用颜色框从视图到控制器发布值。第一次它完全正常工作,但当我重新打开颜色框时,它将旧值发布到新的。

这是我的彩盒代码:

$('#equipmentPopup').colorbox({
    ajax: true,
    width: "620px",
    height: "450px",
    href: showEquipment,
    data: {
        briefingId: $("#briefing_id").val(),
        briefingDate: $("#Briefing_scheduled_date").val(),
        briefingEndDate: $("#Briefing_scheduled_end_date").val(),
        briefingEquipments: $('#BriefingEquipments').val()
    }
});

这是我的行动代码:

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->render('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,
    ));
}

1 个答案:

答案 0 :(得分:1)

您的代码对我不起作用。我发现colorbox没有传递数据,因此请尝试将data更改为:

data: function() {
    return {
        briefingId: $("#briefing_id").val(),
        briefingDate: $("#Briefing_scheduled_date").val(),
        briefingEndDate: $("#Briefing_scheduled_end_date").val(),
        briefingEquipments: $('#BriefingEquipments').val()
    }
}

也许会有所帮助。