XiboFormRender and XHR

I am working on some custom Xibo functionality. It seems like the rendering functions do not return any useful objects (only false).

I was expecting to call XiboFormRender and receive a Promise so I can then use further handlers. I know you return false so the href doesn’t get handled, but couldn’t you use Event.preventDefault to prevent the event from bubbling up and return the Ajax call instead? I have not seen a particular instance in Xibo where that wouldn’t work, but I just wanted to check.

Even further in the future I would also like to know whether particular form (eg. a delete confirmation) was confirmed or cancelled (I guess with a proper promise I could attach to the buttons).

Right now I subscribe to the global ajaxSuccess handler to “check” when a DELETE was issued which feels a bit dirty.

Calling XiboFormRender consumes the XHR entirely - essentially its a self contained function. Your best bet at the moment is to call the back end yourself.

In all honesty its a very old structure and needs updating. If you’d like to try and patch in support for returning a promise, then please do.

You’ve probably seen that from 1.7 to 1.8 we’ve rewritten the back end, bringing it up to date with modern php. In 1.9/2.0 we will be doing the same for the front-end (fitting nicely onto the API 1.8 brings).

I’ve created a patch that makes XiboFormRender return a chainable object. Let me know if you want me to create a Pull Request.

Thank you - I’ve created a PR and will have @maurofmf review it.