This mini tutorial describes how to highlight a form row in Yii applications, when form controls are clicked.
Below is some code Yii generates for a single form control, e.g. an text input field:
<div class="row"> <?php echo $form->labelEx($model,'intro'); ?> <?php echo $form->textArea($model,'intro',array('cols'=>50,'rows'=>4)); ?> <?php echo $form->error($model,'intro'); ?> </div>
To highlight the div row
when the input element inside the div row is clicked or focused, add this code below the form markup:
Yii::app()->clientScript->registerScript('divRowClicked', 'jQuery("div.row input,textarea,select").on("click focus", function() { // Remove previously highlighted div.rows: jQuery("div.row").css("backgroundColor",""); // Highlight the div.row in a light grey: jQuery(this).parent("div").css("backgroundColor","#EFEFEF"); });');
Comments
No comments