jyoungblood / smoke.js

framework-agnostic styled alert system for javascript
http://smoke.js.org/
930 stars 107 forks source link

Destroy all modals #54

Open dennismonsewicz opened 9 years ago

dennismonsewicz commented 9 years ago

Reworked destroy method to be a little more global, so it can be called by itself from the smoke object. The use case was if using the smoke library with the routing system inside of Backbone. If a user navigates to a route, then proceeds to click the back button in the browser and a smoke modal is open, the modal doesn't close.

Here is how you can get around the issue with Backbone.Router and the changes in this PR:

Backbone.Router.extend({
  execute: function(callback, args) {
    // make sure smoke object is present
    if(smoke.newid) {
        smoke.destroy();   
    }

    if (callback) callback.apply(this, args);
  },

  // other codez
});
trey commented 9 years ago

:+1: