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

Callback method #16

Closed
richgcook opened this issue Jul 17, 2013 · 2 comments
Closed

Callback method #16

richgcook opened this issue Jul 17, 2013 · 2 comments

Comments

@richgcook
Copy link

I'm curious... is there a callback we can use without having to input specific needs into the script?

I've tried hunting around, but I'm keen to add a few callbacks once the ajax method has completed; or better yet, an option beforeAjax and afterAjax.

Thanks,
R

@rdebeasi
Copy link

rdebeasi commented Aug 8, 2013

To run stuff code the Ajax load has completed, you could bind to the statechangecomplete event.

I'm also working on a fork of Ajaxify that has callbacks that are fired before and after the ajax load, plus many other changes and additions. https://github.com/prod4ever/ajaxify

@richgcook
Copy link
Author

Thanks for this, by the way.

I did something like this, which I hope helps others.

function ajaxInit() {
    // All the code you want to retrigger
}

// Call myInit when document is ready.
  ajaxInit();

// Call myInit again after each AJAX load.
  $(window).on('statechangecomplete', function() {
      ajaxInit();
      // Optionally, do other stuff only after an AJAX load.
  });

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

2 participants