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

Change URL of ajax dynamically #40

Open
patrickf0 opened this issue Jun 27, 2015 · 2 comments
Open

Change URL of ajax dynamically #40

patrickf0 opened this issue Jun 27, 2015 · 2 comments

Comments

@patrickf0
Copy link

Hi there,

great plugin! Works nice!

Is there a way to change the url of ajax dynamically?

I have got a task navigation and in order to reuse the autosave.js I need to change the ajax url according to the current opened task. (the task nav hides and shows the forms, so there is no page reload).

@kflorence
Copy link
Collaborator

@patrickf0 you can pass in dynamic data to the ajax save handler but using a function instead of an object -- but that won't work for the url property. You could, alternatively, write your own ajax handler and use it instead of the default one.

@thorne51
Copy link

@patrickf0 What I ended up doing was updating the <form> tag's action attribute dynamically and in the save callback I'd re-read the form's action attribute:

$("#my-form").autosave({
  callbacks: {
    save: {
      method: "ajax",
      options: {
        url: $("#my-form").attr('action')
      }
    }
  }
});

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