Skip to content

Instantly share code, notes, and snippets.

@cyberfly
Created July 7, 2023 12:49
Show Gist options
  • Save cyberfly/4112f5e472b87ea852c8bdd4d642ba7b to your computer and use it in GitHub Desktop.
Save cyberfly/4112f5e472b87ea852c8bdd4d642ba7b to your computer and use it in GitHub Desktop.
<script type="module">
let data = {!! $keywords !!};
$('#example tbody').on('click', 'button', function () {
var data = table.row($(this).parents('tr')).data();
$("#keyword").val(data.keyword);
$("#keyword").focus();
});
let table = new DataTable('#example', {
data: data,
columns: [
{ data: 'id' },
{ data: 'keyword' },
{ data: 'term_group' },
{ data: 'difficulty' },
{ data: 'volume' },
{
data: null,
render: function(data, type, row) {
return '<button type="button" class="choose_keyword inline-flex items-center px-4 py-2 bg-pink-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-pink-700 focus:bg-pink-700 active:bg-pink-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition ease-in-out duration-150">Choose Keyword</button>';
}
}
]
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment