I have a dilemma with clipboard.js
What happens is that I have a couple of cells which I would like to click on the field of the cell is copied to the clipboard. As a test, I did the following:
<script src="https://cdn.rawgit.com/zenorocha/clipboard.js/v1.5.3/dist/clipboard.min.js"></script>
<script>
var clipboard = new Clipboard('.btn');
</script>
And in the view
<table class="table table-bordered btn-hover" id="example1">
<thead>
<tr>
<th>Apellido Paterno</th>
</tr>
</thead>
<?php if (!empty($contratos)): ?>
<?php foreach ($contratos as $contrato): ?>
<tr>
<td id="cp">
<?php echo $contrato->ap_paterno; ?>
<button class="btn" data-clipboard-target="#cp">
Copiar
</button>
</td>
<?php $data_cliente_view =
$contrato->id_cliente . "*" .
$contrato->ap_paterno;?>
</tr>
</table>
What as a result is the following:
Evidently is not practical , I know. But I wanted to see if this script
would work but it was not, if it does, but this example only copies the first value that clicks on the button (fence: if I copy Perez, then I try to copy Gonzalez keeps the value de Perez).
The objective here is that it works (first that you can freely copy all value within the cell) and also remove the button. Thank you very much for taking a look at my problem ...