Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoRelase / manuallyReleaseData #86

Closed
Ahnungsloser opened this issue Oct 14, 2013 · 6 comments
Closed

AutoRelase / manuallyReleaseData #86

Ahnungsloser opened this issue Oct 14, 2013 · 6 comments

Comments

@Ahnungsloser
Copy link

Hi all, I´m new to Sisyphus and jQuery.
I have integrated it to my site. My Form is checked by PHP for mistake, the data is written to MYSQL and the user is redirected to a confirmation site. Now my question. I have added following code to my form site ...

$( function() {
$( "#formdata" ).sisyphus({
autoRelease: false
});
} );
</script>

Input is correct, checked by PHP and user is redirected. How can I clear the data now from the new site ...

I tried $('#formdata').sisyphus.manuallyReleaseData();
but seems not to be workin. Any help for a newbie is apreciated.

@simsalabim
Copy link
Owner

$("#formdata").sisyphus().manuallyReleaseData();

Also you don't need to use backslashes here, they're used to escape strings.
And if you tried to check in console the receiver of the function you were calling $("#formdata").sisyphus // function() you'd see that this is not an object.
Javascript console throws TypeError: $(...).sisyphus.manuallyReleaseData is not a function, please use chrome developer tools or firebug.

@Ahnungsloser
Copy link
Author

Hello simsalbim,
thanks for your reply. I tried your code but it don't work. All data is still there. Instead localStorage.clear(); works. Why?
By the way ... the code is output of my PHP script, so I had to escape the "".

@simsalabim
Copy link
Owner

I can't say why it doesn't work as I didn't see full code. You can check the functionality:

  • go to the demo site
  • fill the first form with some values (change select and text input)
  • reload the page to make sure the data were persisted
  • run in js-console $('#basic_form').sisyphus().manuallyReleaseData()
  • reload the page to make sure the form is cleared

Oh, I've just read the last sentence - I think I don't even want to see that code as having javascript (as well as mark-up, btw) in php is not a brilliant solution.
Instead, if you say that the solution I provided doesn't work, could you please paste the js-console output it generates?

@Ahnungsloser
Copy link
Author

I think the problem is that, as I mentioned in the first post, the call to the manuallyReleaseData() function isn't done on the site where the form is located. I check the user input at input.php where I also call Sisyphus

$(function() {
$("#formdata").sisyphus({
autoRelease: false
});

then I redirect to input-ok.php where no form is availabe. On this site input-ok.php I will manuallyReleaseData().
Think thats the problem an the reason why localStorage.clear(); is working. Is there a problem if I use localStorage.clear(); instead of manuallyReleaseData()?

@simsalabim
Copy link
Owner

If you need to clear sisyphus' data on another page why do you run it with autoRelease: false then????

@SangeethaSiva
Copy link

Hi,
I want my form data need to be released once the form is submitted.
We have this line - autoRelease: true.
But data is not cleared after submit. Can you please guide?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants