Error Jquery UI And Jquery Loader - JS.Class ver 3.0.5

86 views
Skip to first unread message

Hore

unread,
Jan 17, 2012, 4:30:05 AM1/17/12
to jsclass-users

JS.Packages(function() { with(this) {
file('/res/js/jquery/jquery-1.7.js').provides('jQuery');
file('/res/js/jquery/
jquery.ui.min.js').provides('jQueryUI').requires('jQuery');
file('/res/js/
application.js').provides('app').requires('jQueryUI','JS.Class');
}});

File loader.js line number 223
var self = this, fireOnLoad = function(exports) {
self._exports = exports;
if (self._onload) self._onload();
self._isLoaded(true);
self._fire('load');
};

Change self._isLoaded(true); for self._isLoaded();

James Coglan

unread,
Jan 17, 2012, 4:36:47 AM1/17/12
to jsclas...@googlegroups.com
The reason that code is there is to make sure your packages define the objects they claim to define. Without it, it can be very hard to track down errors. If JS.Packages reports 'Expected package at ... to define Foo' you should fix that error, rather than removing the code that warns you about it.

James Coglan

unread,
Jan 17, 2012, 4:39:56 AM1/17/12
to jsclas...@googlegroups.com
On 17 January 2012 09:36, James Coglan <jco...@gmail.com> wrote:
    file('/res/js/jquery/
jquery.ui.min.js').provides('jQueryUI').requires('jQuery');
    file('/res/js/

The problem is probably that the jQuery.UI library does not provide an object called jQueryUI. 

James Coglan

unread,
Jan 17, 2012, 4:42:07 AM1/17/12
to jsclas...@googlegroups.com
Looking at their source, the root object is called `jQuery.ui`. 

Horelvis Castillo

unread,
Jan 17, 2012, 5:16:26 AM1/17/12
to jsclas...@googlegroups.com
You're right James, thank you very much for answering.
I do not understand where you found the name of the object 'jQuery.ui', I thought that was defined by the user in the 'provider'
Thank you.

Tienes razón James, muchas gracias por responderme.
No logro entender donde has encontrado el nombre del objecto 'jQuery.ui',  creía que se definia por el usuario en los 'provides'
Gracias.

2012/1/17 James Coglan <jco...@gmail.com>



--
Atte.

Horelvis Castillo Mendoza

Móvil : 638 84 29 18

Innovasoft New Tecnologic S.L.
Centro de Negocios Ofialia,
C/ Castillo de Monteagudo, Parc. 9/3-4
Pol. Ind. Base 2000
30564 - Lorquí - Murcia
Tlfno. : 968 67 63 39


James Coglan

unread,
Jan 17, 2012, 6:20:38 AM1/17/12
to jsclas...@googlegroups.com
On 17 January 2012 10:16, Horelvis Castillo <hcastill...@gmail.com> wrote:
You're right James, thank you very much for answering.
I do not understand where you found the name of the object 'jQuery.ui', I thought that was defined by the user in the 'provider'

No, JS.Packages is designed to work with the object names actually provided by libraries. The provides() call tells the loader which objects exist in a file, so it knows what to download when you want to use something. It uses object detection, so if you used 'jQueryUI' as the name, every time you call JS.require('jQueryUI') it would see that object does not exist and potentially re-download the library. If you use 'jQuery.ui' instead, the object detection kicks in and it won't download code unless the object is missing.

I found the jQuery.ui object here:

Horelvis Castillo

unread,
Jan 17, 2012, 6:39:18 AM1/17/12
to jsclas...@googlegroups.com
Thanks James, you're right I will consider it for development.
It is advisable to separate you from making each object in a single file for downloading otimizar?

2012/1/17 James Coglan <jco...@gmail.com>

James Coglan

unread,
Jan 17, 2012, 6:42:44 AM1/17/12
to jsclas...@googlegroups.com
On 17 January 2012 11:39, Horelvis Castillo <hcastill...@gmail.com> wrote:
Thanks James, you're right I will consider it for development.
It is advisable to separate you from making each object in a single file for downloading otimizar?

I tend to put each class/module in its own file, but this is to optimize for development rather than deployment. You can use the `jsbuild` tool to bundle files for production. I've been meaning to blog about how Songkick uses it for ages, will try and get to it this week. 
Reply all
Reply to author
Forward
0 new messages