jsonform / jsonform

Build forms from JSON Schema. Easily template-able. Compatible with Bootstrap 3 out of the box.
https://jsonform.github.io/jsonform/playground/index.html
MIT License
2.72k stars 553 forks source link

[Question] How to get the markup of the form programatically in JS without attaching it to a DOM element #429

Closed naveenvalecha closed 1 year ago

sdetweil commented 1 year ago

I don't think you can BUT the DOM element doesn't have to be IN the DOM

I think u can create a div element and use that as the target. and then use element.innerHtml to get the html text

let form_div = document.createElement('div')  // create element, not in DOM
form_div.jsonform(form_object)  // generate form DOM elements, with div as parent
let form_html_text=form_div.innerHtml  // extract form html content
sdetweil commented 1 year ago

because jsonform is a Dom content generator it needs to be done in a runtime supporting Dom operations, not just node.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.