Deform with use_ajax and jQueryForm

668 Views Asked by At

When a form is submitted, I'm validating it with Deform. If validation fails I'm passing back the same form with validation warnings attached, and it is replacing the old form. This works fine with AJAX, the first time. After the first time, it appears that the submit button of the Deform form is no longer bound.

When the page first loads, and deform_loaded === true, the deform.callbacks array is empty. However, the form properly submits via ajax. After the second go-round, deform.callbacks now contains 1 array mapping my from to a callback. However, when I now submit, ajax isn't used and the page refreshes.

How can I get the updated form's submit to be bound like the original form's submit?

2

There are 2 best solutions below

0
On

I had to add a call for the deform.processCallbacks-method after rendering the form in order to make the ajax form work. The contents of my mako-template file is:

${form | n}
<script type="text/javascript">
    deform.processCallbacks();
</script>

So it first renders the form (with or without errors) and afterwards calls to process the Callback on all form fields. The processing of callbacks enables the buttons for submitting the form. Works at least in deform 0.9.5.

This is indeed an old post, but I was struggling with the deform/ajax myself a while back. I hope this can help somebody else.

0
On

It seems to work fine on the http://deformdemo.repoze.org/ajaxform/(deform demo).

This is two months old however, so maybe you got it working?