Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @if ($crud->hasAccess('update'))
- <a href="javascript:void(0)" onclick="updateEntry(this)"
- data-route="{{ url($crud->route.'/'.$entry->getKey().'/markasread') }}" class="btn btn-sm btn-link"
- data-button-type="update"><i class="la la-book"></i> Mark as {{$entry->is_read == '1' ? 'unread' : 'read'}}</a>
- @endif
- {{-- Button Javascript --}}
- {{-- - used right away in AJAX operations (ex: List) --}}
- {{-- - pushed to the end of the page, after jQuery is loaded, for non-AJAX operations (ex: Show) --}}
- @push('after_scripts') @if (request()->ajax()) @endpush @endif
- <script>
- console.log(this);
- if (typeof updateEntry != 'function') {
- $("[data-button-type=update]").unbind('click');
- function updateEntry(button) {
- // ask for confirmation before deleting an item
- // e.preventDefault();
- var route = $(button).attr('data-route');
- $.ajax({
- url: route,
- type: 'POST',
- dataType: "json",
- data: [
- {
- "id": {{$entry->getKey()}}
- }
- ],
- success: function(result) {
- // Show an alert with the result
- console.log(result,route);
- new Noty({
- text: {{$entry->is_read == '1' ? 'Marked as unread' : 'Marked as read'}},
- type: "success"
- }).show();
- // Hide the modal, if any
- $('.modal').modal('hide');
- crud.table.ajax.reload();
- },
- error: function(result) {
- // Show an alert with the result
- new Noty({
- text: "Error",
- type: "warning"
- }).show();
- }
- });
- }
- }
- // make it so that the function above is run after each DataTable draw event
- // crud.addFunctionToDataTablesDrawEventQueue('deleteEntry');
- </script>
- @if (!request()->ajax()) @endpush @endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement