Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

TypeError: $.cancel_autosave is not a function

edited December 2013 in Framework

I added <a href="javascript:history.go(-1)" onclick="return $.cancel_autosave ('{"Are you sure you want to cancel and lose any changes?"}')">{"Cancel"}</a> to one of my views but I was getting TypeError: $.cancel_autosave is not a function in the js console.

I tested the default user handler/view, which is where I copied from, but it throws the same error. Same thing on the elefant demo site. I fixed it by adding

$page->add_script ('/js/json2.js');
$page->add_script ('/js/jstorage.js');
$page->add_script ('/js/jquery.autosave.js');

to the handler.


  • Your fix is correct. You have to include jquery.autosave.js (which also depends on json2.js and jstorage.js), since that's where $.cancel_autosave() is defined. Some steps to setting it up are found in the header comments in the script as well.

  • Do you want to add it to apps/user/handlers/edit.php and apps/user/handlers/add.php?

  • Oops! Just fixed those. Thanks for pointing that out :)

Sign In or Register to comment.