Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Søren Kottal 712 posts 4570 karma points MVP 6x c-trib
    Nov 16, 2016 @ 15:06
    Søren Kottal
    0

    Clicking previous in an ajax enabled form goes forward

    Hi

    I'm trying to AJAX enable a form with several pages. I did this piece of js:

          function bindContour() {
    
              //currentForm and other variables, is of course defined in the function
    
              currentForm.find("form").on("submit", function (e) {
              e.preventDefault();
              var form = $(this);
    
              if (form.data('submitted') === true) {
                  // Previously submitted - don't submit again
              } else {
                  if (form.valid()) {
                      // Mark it so that the next submit can be ignored
                      $.ajax({
                          url: $(this).attr('action'),
                          type: 'POST',
                          cache: false,
                          data: new FormData(this),
                          processData: false,
                          contentType: false,
                          success: function (data) {
    
                              var newform = $(data).find("#" + modalId);
                              modalContent.html(newform.html());
    
                              bindContour();
                          }
                      })
                  }
                  else {
                  }
              }
    

    The first submission works fine, the second also works (if only you go forward). If I click Previous, the form just acts like I clicked next.

    Is there something I'm missing?

Please Sign in or register to post replies

Write your reply to:

Draft