Hi,

> how would jsPax accomplish:
>
> $("user").each(function(){
>     $.jsanUse('com.myapp.userClass');
>     com.myapp.userClass.doSomething(this);
> });
>
> Where com.myapp.userClass.doSomething is passed the selected user?
>
> Would it have to be this?
> $using('com.myapp.userClass', function() {
>     $("user").each(function(){
>         com.myapp.userClass.doSomething(this);
>     });
> });

You can also write

$("user").each(function(){
    $using('com.myapp.userClass', function() {
            com.myapp.userClass.doSomething(this);
    });
});


Then 'com.myapp.userClass' is loaded for the first "user"-Element if there is 
any. The each() runns through all Elements and after the first element, 
$using() just notices that 'com.myapp.userClass' is already on its way to 
come and deferres the callback. As soon as 'com.myapp.userClass' is available 
all pending callbacks are executed. each() returns immediatelly.

> Overall I think we both agree that namespace based on-demand package
> loading is a valuable asset to any JS developer.

Yes :-)

Christof

Reply via email to