Skip to content

Commit

Permalink
Move pengines.js browser network initialization
Browse files Browse the repository at this point in the history
See Issue #44. Network initialization for browser code moved to constructor so load always succeeds independent of whether jQuery has initialized.
  • Loading branch information
ridgeworks authored Feb 22, 2019
1 parent e817d7f commit e605111
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions web/js/pengines.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ function Pengine(options) {
}
}

// initialize network support in browser
if (typeof Pengine.network === "undefined") {
Pengine.network = $; // assume jQuery initialized by now
$(window).on("beforeunload", function() {
Pengine.destroy_all();
});
}

// create instance
this.options = fillDefaultOptions(options);
this.id = null;
Expand Down Expand Up @@ -678,10 +686,4 @@ if (typeof window === 'undefined') {
var najax = require('najax');
Pengine.network = najax;
Pengine.network.ajax = najax;
} else {
Pengine.network = $;
// Browser
$(window).on("beforeunload", function() {
Pengine.destroy_all();
});
}

0 comments on commit e605111

Please sign in to comment.