1 (edited by caesar2k 2009-12-29 10:01:08 AM)

Topic: Jquery-ready xajax_core!!!

Okay, I had the time to extend the xajax_core functions. I've managed to call jQuery directly from PHP like this:
$objr->assign('#menu-lateral #menu li:eq(1)','innerHTML',$data);

This modification allows you to use jQuery as your DOM selector whenever it's detected on the includes of the page!

xajax.tools.$ = 
function(sId){
  if (!sId) return null;
  if (window.jQuery) { // Detects if jQuery is present!
    var nonmatch = /[^\a-z0-9]+/i; // Legacy support, check if the ID is being called directly!
    if (!sId.match(nonmatch)) { sId = '#' + sId; } // Add the "ID" hash to the name
    var obj = jQuery(sId); // Select the object
    return obj?obj[0]:null; // Return object safelly!
  } else { // No jquery present, vanilla XAJAX!
    var oDoc = xajax.config.baseDocument;
    var obj = oDoc.getElementById(sId);
    if(obj) return obj;
    if(oDoc.all) return oDoc.all[sId];
    return obj;
  }
  return null; // Just in case :P
}

I had to use this, because I had two #menu in different namespaces (#menu-lateral #menu and #header #menu). Hope somebody will find it useful as well!
Now I plan to modify it even further to allow a call to the jQuery object directly, like $objr->assign('#menu','css',array('background-color' => '#fff')); not sure if its overkill or anything lol

Re: Jquery-ready xajax_core!!!

nice! thanks

Using xajax 0.5

Re: Jquery-ready xajax_core!!!

Its very nice. Something to include permanently into xajax.

Re: Jquery-ready xajax_core!!!

I did some tests by replacing the xajax.getFormValues() with jquery, it turned out nicely. And I got about 1.5 times the speed of the normal call (but due to the performance you would never notice it).

Maybe it's a good enhancement for the existing xajax javascript core. But since it can be a fairly large modification it should be supported by a wide group of users (and the project leaders of course).