2014-03-13 32 views
3

工作,請參見下面的代碼:TBBUTTON復位不與redactorRow

<?php 
$label = $model->isNewRecord ? 'Create' : 'Update'; 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
    'id' => 'article-form', 
    'type' => 'horizontal', 
)); 
?> 
<fieldset> 
    <legend><?php echo $label ?> Article</legend> 
    <?php 
    echo $form->textFieldRow($model, 'title', array('class' => 'span5', 'maxlength' => 200)); 
echo $form->redactorRow($model, 'content'); 
?> 
</fieldset> 
<div class="form-actions"> 
    <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $label)); ?> 
    <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'reset', 'label' => 'Reset')); ?> 
    <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'link', 'url' => url('article/index'), 'label' => 'Cancel')); ?> 
</div> 
<?php $this->endWidget(); ?> 

首先我鍵入字段:標題(文本字段)和內容(主編) 其次,我單擊Reset按鈕 =>結果:只是標題字段爲空文本,不適用於內容。

請幫我這麼做!

感謝和問候,

回答

0

我還沒有發現問題。 但我有jQuery的解決方案。

<?php 
cs()->registerScript('reset', " 
    var firstContent = []; 

    $('.redactor_editor').each(function(index, value) { 
     firstContent.push($(this).html()); 
    }); 

    $(document).ready(function() { 
     $('button[type=\'reset\']').click(function() { 
      $('.redactor_editor').each(function(index, value) { 
       $(this).html(firstContent[index]); 
      }); 
     }); 
    }); 
", CClientScript::POS_LOAD); 
?> 

它工作正常!

有人有其他解決方案嗎? 請在這裏分享!

非常感謝!