AJS 4.1

Some days ago I released a AJS 4.1 and it has some nice improvements.

Minify improved

Now one can minimize AJS even if functions aren't prefixed with AJS.. For example, for iRemind I got AJS down to 11 KB (from 35 KB).

For most of my projects I export AJS to the global scope, since it's really tedious to type AJS. all the time. One can use the JavaScript module pattern to still keep the namespaces clean:

(function() {
    AJS.exportToGlobalScope(this);
    var span = SPAN({c: 'highlight', s: 'color: red'}, 'This is a test');
    RCN(getBody(), span);
}());

Small shortcuts

I create a lot of DOM in JavaScript and I was really tired of typing 'class': and 'style':, so in the new version one can do this:

var span = SPAN({c: 'highlight', s: 'color: red'}, 'This is a test');

Intead of:

var span = SPAN({'class': 'highlight', style: 'color: red'}, 'This is a test');

Notice that you have to use 'class', since class is a keyword. It's a small improvement, but saves some keystrokes.

Announcements · Code · JavaScript · Tips 31. Aug 2007
4 comments so far

i was having troubles working with the ajax stuff with AJS... and ended up using jQuery.

Braydon:
What kind of troubles?

Been trying to get ajax_yahoo_img_search.html demo to work. Is there something amiss?

amix:
I couldn't figure out how to load a url with AJS. The part i got confused with was how to do something similar to this (w/ jQuery):


$("#page_"+page_number).load(pages[page_number]);

Here is are some of the other surrounding pieces:


function processQue() {
if(load_que.length > 0) {
page_number = load_que[0];
load_que.shift();
$("#dock").prepend("... div w/ id page_pagenumber ... ");
$("#page_"+page_number).load(pages[page_number]);
pages_loaded[page_number] = true;
}
}

function stagePage(page_number) {
if(pages_loaded[page_number]) {
$("#stage").children().appendTo("#dock");
$("#dock > #page_"+page_number).appendTo("#stage");
current_page = page_number;
}
}

note. was having some trouble with getting the ... div w/ ... section above to show up. so i replaced it with that to get the point across.

Post a comment
Commenting on this post has expired.
© 2000-2009 amix. Powered by Skeletonz.