surveyjs / survey-creator

Scalable open-source survey software to generate dynamic JSON-driven forms within your JavaScript application. The form builder features a drag-and-drop UI, CSS Theme Editor, and GUI for conditional logic and form branching.
https://surveyjs.io/open-source
Other
900 stars 372 forks source link

Custom save button with disabled state in survey editor #3090

Open hekin1 opened 2 years ago

hekin1 commented 2 years ago

Are you requesting a feature, reporting a bug or ask a question?

Asking a question

What is the current behavior?

The default save icon in survey creator is a small floppy disk. I added a custom button to my html page, which will save the survey to backend.

<button type="button" v-on:click="saveSurveyToBackend()">Save</button>

What is the expected behavior?

However, this button is always enabled. I would like it to act as the floppy-icon which is disabled/enabled based on if the user has done any changes to the survey-json object.

Is it possible to get true or false from your survey creator api, if any changes has been done by the user in the editor?

Thanks!

andrewtelnov commented 2 years ago

@hekin1 You can use creator.onModified event and check their creator.state === "modified" to enable button and disabled it on saving. the state becomes (creator.state), "saving" or "saved".

Thank you, Andrew