Export camperUploadForm function
I did not remember that the file was loaded as a module, so i have to export it in order to use from the <script> in media. That <script> needs to be also a module and explicitly import the function; since it is already loaded, the browser does not load the file again.
This commit is contained in:
parent
4aa74c0768
commit
233aacc2de
|
@ -113,7 +113,7 @@ ready(function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function camperUploadForm(el) {
|
export function camperUploadForm(el) {
|
||||||
const progress = el.querySelector('progress');
|
const progress = el.querySelector('progress');
|
||||||
htmx.on(el, 'drop', function (evt) {
|
htmx.on(el, 'drop', function (evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
|
|
@ -32,7 +32,10 @@
|
||||||
<progress value="0" max="100"></progress>
|
<progress value="0" max="100"></progress>
|
||||||
</footer>
|
</footer>
|
||||||
</form>
|
</form>
|
||||||
<script>camperUploadForm(document.getElementById('mediaPickerUpload'))</script>
|
<script type="module">
|
||||||
|
import {camperUploadForm} from "/static/camper.js";
|
||||||
|
camperUploadForm(document.getElementById('mediaPickerUpload'));
|
||||||
|
</script>
|
||||||
<form action="/admin/media/field" method="get" data-hx-boost="true" data-hx-push-url="false">
|
<form action="/admin/media/field" method="get" data-hx-boost="true" data-hx-push-url="false">
|
||||||
{{ with .Field -}}
|
{{ with .Field -}}
|
||||||
<input type="hidden" name="name" value="{{ .Name }}"/>
|
<input type="hidden" name="name" value="{{ .Name }}"/>
|
||||||
|
|
|
@ -28,5 +28,8 @@
|
||||||
<progress value="0" max="100"></progress>
|
<progress value="0" max="100"></progress>
|
||||||
</footer>
|
</footer>
|
||||||
</form>
|
</form>
|
||||||
<script>camperUploadForm(document.getElementById('mediaUpload'))</script>
|
<script type="module">
|
||||||
|
import {camperUploadForm} from "/static/camper.js";
|
||||||
|
camperUploadForm(document.getElementById('mediaUpload'));
|
||||||
|
</script>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
Loading…
Reference in New Issue