Back button working, but...

johnoathome 17 May, 2015
Hi,

I followed the guide at http://www.chronoengine.com/forums/posts/f2/t95332.html?page=3 to implement a back button in a multipage form with AJAX submit.

It works, but when the previous page loads, it replaces the form contents with the entire page (e.g. header, menus and so on) instead of just redisplaying the previous form page.

The setup is like this:
Form name: SkilledPointsCalculator
Hidden Field ID: #back2page1 (Extra params alt=ghost)
Button ID: #back-btn


This is the code:
jQuery(document).ready(function(){ 
    jQuery(document).on('click', '#back-btn', function(){
        jQuery.ajax({
            "type" : "POST",
            "url" : jQuery("#back2page1").val(),
            "success" : function(res){
                jQuery("#chronoform-SkilledPointsCalculator").replaceWith(res);
            }
        });
    });

});
Am I missing something obvious?

Thanks
John
GreyHead 25 May, 2015
Hi johnoathome,

Please see Max's last post in the other thread ". . . I forgot something though, the url must end with &tvout=ajax " I think that will fix it.

Bob
johnoathome 25 May, 2015
Hi Bob,

Thanks for getting back.

Actually I've now installed the FullAJAX plugin from the JED. The advantage is that it manages history and is SEO friendly. The down side is that AJAX pages don't fire document ready so you have to make other arrangements.

For anyone who is interested, to get around this I've created a common set of functions that are called by a load event in the form if it is loaded conventionally and as a call back from the AJAX request if loaded by AJAX.

Essentially it means I need to have most of the event code outside of the form. Not as convenient as using the inbuilt field events but I just love the user experience with AJAX.

Cheers
John
This topic is locked and no more replies can be posted.