yii怎么用ajax动态的增加或删除表单元素
发布网友
发布时间:2022-04-07 07:18
我来回答
共1个回答
热心网友
时间:2022-04-07 08:47
您好,很高兴为您解答。
直接jquery绑定方法 before() 添加
三段代码放在三个文件里。
[attach]756[/attach][code]
<tr>
<th><?php echo WorkExperience::model()->getAttributeLabel('start_date')?></th>
<th><?php echo WorkExperience::model()->getAttributeLabel('end_date')?></th>
<th><?php echo WorkExperience::model()->getAttributeLabel('organization_name')?></th>
<th><?php echo WorkExperience::model()->getAttributeLabel('job_title')?></th>
<th> <?php echo $batchStudents->status?"":CHtml::link(t('Add'), 'javascript:void(0);', array('onClick'=>'addWorkExperience($(this))', 'class'=>'add'));?></th>
</tr>
<?php foreach($workExperienceManager->items as $id=>$workExperience){
$this->renderPartial('workExperienceform', array('id'=>$id,'model'=>$workExperience, 'form'=>$form));
} ?>
</table>
<?php $this->renderPartial('workExperienceJs', array('workExperiences'=>$workExperienceManager, 'form'=>$form));?>
[/code][code][/code][code]
<td>
<?php
echo $form->textField($model,"[$id]start_date",array('style'=>'width:100px','class'=>'hashDatepicker',
'onClick'=>"$('.hashDatepicker').datepicker({
dateFormat: 'yy-mm-dd',
changeYear: true
});")); ?> <?php echo $form->error($model,"start_date"); ?>
</td>
[/code]
<?php echo $form->textField($model,"[$id]end_date",array('style'=>'width:100px','class'=>'hashDatepicker' ,
'onclick'=>"$('.hashDatepicker').datepicker({
dateFormat: 'yy-mm-dd',
changeYear: true
});")); ?>
<?php echo $form->error($model,"[$id]end_date"); ?>
</td>
<td>
<?php echo $form->textField($model,"[$id]organization_name",array('size'=>20)); ?>
<?php echo $form->error($model,"organization_name"); ?>
</td>
<td>
<?php echo $form->textField($model,"[$id]job_title",array('size'=>20)); ?>
<?php echo $form->error($model,"job_title"); ?>
</td>
<td> <?php echo CHtml::link(
t('Delete'),
'javascript:void(0);',
array(
'class'=>'delete',
'onClick'=>'deleteWorkExperience($(this))',
));?>
</td>
如若满意,请点击右侧【采纳答案】,如若还有问题,请点击【追问】
希望我的回答对您有所帮助,望采纳!
~ O(∩_∩)O~