For example, I have this in MyTable.php:
protected function fields()
{
return [
Text::create('name')
->label('Nome')
->formatUsing(function($value, $row) {
return '<span data-bs-toggle="tooltip" title="'. $value .'">'. mb_strimwidth($value, 0, 14, '...') .'</span>';
})
];
}
In the [https://getbootstrap.com/docs/5.0/components/tooltips/](Bootstrap docs) they tell my to initialize the tooltips as:
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
})
If I run it in the console, it works.
So I have 3 questions here:
- How to run this JS code for this component and others when needed?
- How to run any JS code when I want, like an simple alert('Ok') insde dashboard onRendered? With Client class? If so, how is the sintaxe?
- Koolreport/Dashboard has it own way to start Bootstrap tooltips already?