Single page app with embedded xform

classic Classic list List threaded Threaded
5 messages Options
j3f
Reply | Threaded
Open this post in threaded view
|

Single page app with embedded xform

j3f
Trying to use the xform engine with standard xforms from a single page app with java backend.  Would like to intercept form submission request and response using javascript and render response in a page element such as a div on existing page instead of rendering form response as a new page.  I've investigated a few different approaches but I'm wondering if there is a standard way to do this using orbeon.  I've seen some documentation that suggests this is a common use case but I can't seem to figure out if orbeon has some "hooks" or best way of doing it.  Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Single page app with embedded xform

Alessandro  Vernet
Administrator
Hi Jeff,

I am not sure that I am really following you. Are you talking of "injecting" a form produced by Orbeon Forms into an HTML page, entirely with JavaScript? And about intercepting an xf:submission replace="all" so it is not the whole page that gets replaced?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
j3f
Reply | Threaded
Open this post in threaded view
|

Re: Single page app with embedded xform

j3f
Yes Alex you have described what I would like to do.  Injecting the form into an html page seems a little more straightforward but I'm trying to come up with the best solution for not replacing the whole page on submission.  Thanks
j3f
Reply | Threaded
Open this post in threaded view
|

Re: Single page app with embedded xform

j3f
Would this be standard xform functionality provided by the submission replace attribute for example replace="instance" or replace="all" with a reference to the id of the element that the content needs to be replaced.
Reply | Threaded
Open this post in threaded view
|

Re: Single page app with embedded xform

Alessandro  Vernet
Administrator
Hi Jeff,

Replacing just part of the page as a result of an xf:submission replace="all" isn't currently supported. Instead of telling the browser to do a form POST, we would need to do an Ajax request that returns the HTML and do the replacement in JavaScript (.innerHTML = …). This sounds simple, and at some point we had made some efforts towards that, but doing this creates all kind of little issues related to JavaScript initialization that need to be resolved. For now, I created a higher level RFE, since this is something we'd like to support:

https://github.com/orbeon/orbeon-forms/issues/1577

For now, can you think of a way to avoid doing a submission replace="all"?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet