My issue is const SELECTED_CATEGORY_ID
I have these sets of scripts in my index.blade.php in my laravel:
@section('scripts')
<script type="text/javascript">
const PROFILE_NON_BBR_EXTERNAL_ROUTE = "{{ route('non-bbr-external') }}";
const BBR_GROUP_NAME = "{{ route('bbr-group-configuration-all') }}";
const DATATABLE = "{{ route('bbr-category-configuration-datatable') }}";
const SELECTED_CATEGORY_ID = data.category_id;
</script>
<script type="text/javascript" src="{{asset('js/sweetalert.min.js')}}"></script>
<script src="{{asset('/modules/bbr-category-configuration/js/app.js')}}"></script>
@endsection
in the last script: app.js, there is a value inside a button that I need to retrieve which is:
value="${row.category_id}"
below is the full output for a bit of context.
let TABLE = $('#categoryList').DataTable({
columns: [
{ data: 'id', name: 'id', width: '10%', orderable: false, searchable: false,
render: (data, type, row) =>{
let html = "";
if(row.category_name && row.category_name.toUpperCase() !== "GENERAL"){
html += `<ul class="list-inline no-margin">`;
html += `<li class="list-inline-item">
<button type="button" value="${row.category_id}" id="edit_category" class="edit_category btn btn-outline-secondary"><i class="fas fa-edit" aria-hidden="true"></i> Edit</button>
</li>`;
html += `</ul>`;
}
return html;
}
}
});
What do I need to use in order to retrieve that data from app.js? Using this one will just get me DATATABLE is not defined error:
const SELECTED_CATEGORY_ID = data.category_id;
UPDATE: