Skip to content

Commit b8475c2

Browse files
committed
fix: wrong url generated when ajax is not set
fix: #33
1 parent dbb913e commit b8475c2

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/resources/views/export-button.blade.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,18 @@
22
<form class="mr-2"
33
x-on:submit.prevent="
44
$refs.exportBtn.disabled = true;
5-
var url = window._buildUrl(LaravelDataTables['{{ $tableId }}'], 'exportQueue');
6-
$.get(url + '&exportType={{$fileType}}&sheetName={{$sheetName}}&emailTo={{urlencode($emailTo)}}').then(function(exportId) {
5+
var oTable = LaravelDataTables['{{ $tableId }}'];
6+
var baseUrl = oTable.ajax.url() === '' ? window.location.toString() : oTable.ajax.url();
7+
8+
var params = new URLSearchParams({
9+
action: 'exportQueue',
10+
exportType: '{{$fileType}}',
11+
sheetName: '{{$sheetName}}',
12+
emailTo: '{{urlencode($emailTo)}}',
13+
});
14+
15+
$.get(baseUrl + '?' + params.toString() + '&' + $.param(oTable.ajax.params()))
16+
.then(function(exportId) {
717
$wire.export(exportId)
818
}).catch(function(error) {
919
$wire.exportFinished = true;
@@ -25,7 +35,7 @@ class="{{ $class }}"
2535
@endif
2636

2737
@if($exporting && !$exportFinished)
28-
<div class="d-inline" wire:poll="updateExportProgress">Exporting...please wait.</div>
38+
<div class="d-inline" wire:poll.10s="updateExportProgress">Exporting...please wait.</div>
2939
@endif
3040

3141
@if($exportFinished && !$exportFailed && !$autoDownload)

0 commit comments

Comments
 (0)