opitzconsulting / jquery-mobile-angular-adapter

jquery mobile angular adapter
MIT License
517 stars 114 forks source link

Problem with require.js #22

Closed kapsi1 closed 12 years ago

kapsi1 commented 12 years ago

The 1.0.6 version works when loaded from of index.html, but when loading with require.js, I get this:

Uncaught TypeError: Cannot set property 'globalScope' of undefined       (line 27706)
GET http://localhost:1234/adaptertest/jquery.js 404 (Not Found)
Uncaught Error: Load timeout for modules: jquery 
http://requirejs.org/docs/errors.html#timeout
tbosch commented 12 years ago

Yes, you are right. This is the case as of jquery mobile 1.1 rc1. This is due to the fact the jquery-mobile now is AMD compatible, while the adapter is not. By this, when you use requirejs and optimize everything into one module, jquery-mobile is not initialized directly, but the adapter is.

As a workaround, disable the AMD support of jquery-mobile in the first lines:

if ( typeof define === "function" && define.amd ) {
    // AMD. Register as an anonymous module.
    define( [ "jquery" ], function ( $ ) {
        factory( $, root, doc );
        return $.mobile;
    });
} else {
    // Browser globals
    factory( root.jQuery, root, doc );
}

Replace this with:

    // Browser globals
    factory( root.jQuery, root, doc );

Although this patch you can then still include jquery mobile in a project using requirejs.

In the next release of the adapter, I will add a fix so that the adapter plays more nicely with requirejs (by using the mobileinit event of jquery mobile...).

Tobias

kapsi1 commented 12 years ago

Thanks.

tbosch commented 12 years ago

As of 1.0.7 RC1 this is working again.

Tobias