我使用Yii2进行开发,并尝试使用加号按钮将行添加到表中。
我可以从中添加新行。我需要将Krajee Select2附加到我的追加行。那可能吗?我怎么能这样做?
以下是我的代码用于追加。
$('#main_tbl_body').append(
'<tr class='+row_class+' id="tbl_rw_appent_'+new_count+'">\n\
<td><a onclick ="removeMoreCommentField(this.id)" id="a_link_remove_'+new_count+'"><img id="image_remove_'+new_count+'" src="images/minus.png" style="width: 20px;height: 20px;cursor: pointer;" ></a></td>\n\
<td><div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">'+' <?php
//echo '<label class="control-label">Part Code</label>';
$data = ArrayHelper::map(Mproduct::find()
// where(['P_model' => $model->relatedToVehicle->V_model])
->all(), 'idProduct', 'P_description');
//$items = DealerHelper::getRemainItems();
echo Select2::widget([
'name' => 'part_description_1',
'data' => $data,
'options' => [
// 'class'=>'textBox mobviewmargin',
'placeholder' => 'Select Product',
// 'multiple' => true
],
'pluginOptions' => [
'closeOnSelect' => true,
'tags' => false,
'multiple' => false,
'allowClear' => false,
],
]);
?>'+'</div></td>\n\
<td></td>\n\ \n\\n\
<td></td>\n\ \n\\n\
<td></td>\n\ \n\
<td></td>\n\ \n\
<td><a onclick ="addMoreCommentField()" id="a_link_add_'+new_count+'"><img id="image_add_'+new_count+'" src="images/plus.png" style="width: 20px;height: 20px;cursor: pointer;" ></a></td>\n\
</tr>'
);
请帮帮我