How to call "save form" programmatically

I have janitor plugin button, which generates PDF.

              actionPDF:
                type: janitor
                label: Download PDF
                progress: Downloading PDF...
                job: downloadPdf

I need to call “save” before that button is called. Is it possible?

I could listen for all “click” events on form, then I would check the target, and if it is correct - I could call form.submit() in js (I’m afraid the sequence of events can be messy in that case). Would that work? Or is there any correct way for doing that?

In general I need a way to be able to call “save”, and after save completed, call “downloadPdf”.

You can make the button disabled when there are unsaved changes: Panel Field Option: Unsaved Changes · bnomei/kirby3-janitor Wiki · GitHub That would at least force users to click save before they can trigger the button.

1 Like

Thank you, good idea - I will use it if it is not possible otherwise. But client insists on autosave on click - is that possible?

I don’t know, that’s a question for @bnomei

i created an idea issue. i might give it a shot in the next few days.

if implemented it would work like this

actionPDF:
                type: janitor
                label: Download PDF
                progress: Downloading PDF...
                job: downloadPdf
                autosave: true # <--- i will try to add this to janitor
1 Like

thank you!

done in v2.9.0. but its a bit of a hack. it will save, refresh the page and then press the janitor button again.

this means you will get a blink on refresh and will loose current scrolling position. the later i could reapply but decided against since i found it too invasive.

1 Like

Yes, I see - it is a hack, but it is much better, than nothing :slight_smile: thank you