ruby-on-rails-3turbolinksalertify

getting alertify to work with turbolinks


I am trying to use turbolinks in a rails 3 app. Everything is fine, except that Alertify stops working after a page change.

I have installed the jquery-turbolinks gem to patch it up, but this has had no effect.

I have also tried wrapping the alertify function and triggering it on page:change, but again no joy.

Anyone have issues with turbolinks?


Solution

  • Anyone who encounters this with Alertify 0.4.0 (currently RC1) can solve this by reseting the Alertify elements you're using. In my case, it was Alertify.dialog:

    Alertify.dialog.el = false
    // Do your normal JS stuff
    

    In my crude understanding of this, Alertify thinks that a dialog element has been created, but when Turbolinks loads a page, it destroys that element. We need to tell Alertify it has been destroyed and Alertify will recreate it.

    If you need any help with specifics, let me know.