How to run code if yepnope returns true?

161 Views Asked by At

I use yepnope.js to load a polyfill (Intl). If window.Intl doesn't exist, it loads my polyfill, and executes some code. However, if windows.Intl does in fact exist, I need to execute another code, and I havn't been able to figure out how.

Here is what I have:

yepnope({
  test  : window.Intl,
  nope  : ['lib/Intl.min.js'],
  callback: function(u,r,k){
    $.ajax({
      type: "GET",
      url: 'sv-SE.json',
      dataType: "json",
      success: function(data) {
        Intl.__addLocaleData(data,"sv-SE");
        self.numberFormatter = new Intl.NumberFormat("sv-SE");
      }
    });
  },
  complete: function(){

     /* Do stuff! */

The code I need to run if window.Intl already exists is self.numberFormatter = new Intl.NumberFormat("sv-SE");, but I can't figure out how, as callback is only called on false, as far as I can tell.

0

There are 0 best solutions below