simsalabim/sisyphus

Unbind a form when using ajax

diofeher opened this issue · 5 comments

Hello!
I want to unbind a form from sisyphus because the site I'm coding uses ajax in a lot of places. What is happening:

1 - I'm binding sisyphus to form
self.sisyphus = $('form').sisyphus();

2 - The form is sent by ajax so in the ajax call I use:
self.sisyphus.manuallyReleaseData();

The tricky part is here, because the method is called, but after this, saveDataTimeout is called again, so the form is sent again!

What should I do?

Solved with the following:
After line 431 I put field.val('')

I will test a little and try a pull request if all is working.

DId you get this to work? I can get
$('#form1').sisyphus.manuallyReleaseData();
to work

I'm using ajax with dynamic switch page and load form using jQuery Mobile. How can I unbind it without release data?

Scenario

(All page is ajax load)

  1. User come into page and input form but not finish form yet.
  2. User move to another page <== ( I want to unbind auto save when user navigate away )
  3. Later on, user come back to input form again <== ( I want to bind the functionality when user navigate to this page again)

From my code below. 'onSave' callback is call every 5 seconds (or faster than that) although the 'verify-form-post' is not available.

var savedForm = $('#verify-form-post').sisyphus({       
    autoRelease : true,
    timeout: 5, // 5 seconds
    onSave: function() {            
        console.log('AUTOSAVE : Saved');
    },
    onRestore: function() {
        console.log('AUTOSACE : Restored');  
    },
    onRelease: function() {
        console.log("AUTOSAVE : Release cache");
    }
});

The way the plugin binds to forms should be revised.

Hello,

Was this issue solved ?

Yours,