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

Problems with using AlertifyJS in Ember-CLI #27

Closed
mikeazo opened this issue Mar 5, 2015 · 1 comment
Closed

Problems with using AlertifyJS in Ember-CLI #27

mikeazo opened this issue Mar 5, 2015 · 1 comment

Comments

@mikeazo
Copy link

mikeazo commented Mar 5, 2015

I'm trying to use AlertifyJS with Ember-CLI and couldn't get AlertifyJS to load properly. Ember-CLI currently has problems with unnamed AMD, which is how AlertifyJS is configured.

To figure out a solution to the problem, I dug through d3js code to see how it works (as it works fine with Ember-CLI). This is how d3 loads

if (typeof define === "function" && define.amd) define(d3);
  else if (typeof module === "object" && module.exports) module.exports = d3;
  this.d3 = d3;

AlertifyJS, on the other hand does:

// CommonJS
    if ( typeof module === 'object' && typeof module.exports === 'object' ) {
        module.exports = alertify;
    // AMD
    } else if ( typeof define === 'function' ) {
        define( [], function () {
            return alertify;
        } );
    // window
    } else if ( !window.alertify ) {
        window.alertify = alertify;
    }

Notice the difference on the AMD, d3 checks for define.amd while AlertifyJS does not. If I add that check into AlertifyJS, the third if case fires and I have access to window.alertify within my project. As a side, also doing what d3 does this.alertify=alertify works too.

I personally like the this.alertify=alertify method, but the window.alertify=alertify is workable.

@MohammadYounes
Copy link
Owner

Thanks for the details. window will be this when the context has no window.(see this line).

I'll add define.amd check soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants