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

Not working after ajax refresh #40

Closed
Zmove opened this issue Aug 5, 2015 · 4 comments
Closed

Not working after ajax refresh #40

Zmove opened this issue Aug 5, 2015 · 4 comments

Comments

@Zmove
Copy link

Zmove commented Aug 5, 2015

Hello,

The script stop working when you call it on ajaxComplete jquery event.

Here is my code

$(document).bind('ready ajaxComplete', function() { 
    $('.blog-post').flip();
});

Here is the error that is displayed when I click on my button that load more blog posts with ajax

Uncaught TypeError: Cannot read property 'axis' of undefined

Any ideas about that error ? My call seems very simple, and it works well unless I click on my load more button.

@Zmove
Copy link
Author

Zmove commented Aug 5, 2015

Temporary fix is to comment the code below line 209 - 215 of jquery.flip.js

      if (options.axis !== undefined || options.reverse !== undefined){
        changeSettings.call(this,options,function(){
          $dom.trigger('flip:change');
          if (callback !== undefined){
            callback.call(this);
          }
        });
      }

I do not see drawback to this (probably because I have a very simple usage of the plugin).

@JemarJones
Copy link
Collaborator

What's going on here is that the element has already been instantiated and its being called as if to change some settings but no settings have been provided. The error message is a bit confusing though. What was your expected outcome? Perhaps you meant .flip("toggle");?

@JemarJones
Copy link
Collaborator

Taking a guess at how your application is structured here, it seems you've got a bunch of blog posts elements that you instantiate at some earlier point, you load some new ones, and then you try the above piece of code to instantiate them all. The problem with that is that you're trying to instantiate the old ones again, and thus you get this error. This actually shouldn't stop all the new elements from being instantiated and should have no effect on the old ones, so i would imagine everything actually works as you need it to. But it's messy and you should probably make sure that you only try to instantiate newly created elements.

There is an issue here of flip not giving a clear enough error message in this case though, so i'll add a clear error message in the next release.

JemarJones added a commit that referenced this issue Aug 6, 2015
JemarJones added a commit that referenced this issue Aug 8, 2015
@Download
Copy link
Collaborator

Download commented Aug 9, 2015

Should be fixed in release v1.0.16.

@Download Download closed this as completed Aug 9, 2015
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