jquery-mobile-babel-safe
Version:
Babe safe version of jQuery mobile
59 lines (40 loc) • 1.16 kB
Markdown
jquery-mobile-babel-safe
========================
This is a ready to use version of jQuery mobile that should work fine if you are
doing any transpiling.
NPM:
npm install jquery-mobile-babel-safe --save
Update *package.json*:
"browser": {
"jquery-mobile": "./node_modules/jquery-mobile-babel-safe/dist/jquery.mobile-1.4.5.js"
},
"browserify-shim": {
"jquery-mobile": {
"exports": "jQuery.mobile"
}
}
This solves the *undefined* `this` variable in jQuery mobile by explicitly
using the `window` object.
*Original IIFE*
```
(function($, window){
// code
})(jQuery, this)
```
*Updated IIFE*
```
(function($, window){
// code
})(jQuery, this || window)
```
Most of the solutions out on the web have a tricks to make this work with CJS
but not so much with babel. I needed a quick way to make this work for a project
so I just added the above little hack for now which seems to be safe.
I will update this project once there is a better way to work with jQuery mobile
and babel.
For now, at least I get to stay stick with `npm` :)
USE AT YOUR OWN RISK.