I have this code in view:
<?php foreach ($display as $disp): ?>
<td><a href="#" id="name" data-type="text" data-pk="<?php echo $disp->id;?>" data-url="<?php echo Yii::$app->request->baseUrl;?>/product/update" ><?=$disp->name?></a></td>
<?php endforeach;?>
This shows all the names but only first name is editable with x-editable.
here is the javascripts used:
$.fn.editable.defaults.mode = 'inline';
$(document).ready(function() {
$('#name').editable();
});
The ID must be unique. this could have done with class.
<?php foreach ($display as $disp): ?>
<td><a href="#" class="name" data-type="text" data-pk="<?php echo $disp->id;?>" data-url="<?php echo Yii::$app->request->baseUrl;?>/product/update" ><?=$disp->name?></a></td>
<?php endforeach;?>
and,
$('.name').editable();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.