Hi,
I try to implement a simple export function in a backend list. If have put a button to the backend list form ...
<button
class="btn btn-success oc-icon-print"
disabled="disabled"
onclick="$(this).data('request-data', {
checked: $('.control-list').listWidget('getChecked')
})"
data-request="onExportGalleyProof"
data-trigger-action="enable"
data-trigger=".control-list input[type=checkbox]"
data-trigger-condition="checked"
data-request-success="$(this).prop('disabled', false)"
data-stripe-load-indicator>
Generate galley proof
</button>
... and added the controller function:
public function onExportGalleyProof()
{
if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds) > 0) {
$html = ... // generates a special html site
file_put_contents(temp_path('galleyproof.html'), $html);
return Response::download(temp_path('galleyproof.html'));
} else {
Flash::error('You have to select an article');
}
}
However, unfortunately, that doesn't work, as the download doesn't start. What is the problem? How can I start a download via AJAX request?