PDA

View Full Version : use jQuery objects in Ext classes



Koc
15 Apr 2010, 12:14 PM
1) where JS code bb-tag?? :-?

2) I'm using jQuery and Ext-jQuery adapter. For what this adapted needed if no possibility put jQuery objects into Ext classes?


// works
var lMask = new Ext.LoadMask(Ext.get('tree'), {msg: '?????????, ????...'});
// doesn't work
var lMask = new Ext.LoadMask($('#tree'), {msg: '?????????, ????...'});

Koc
15 Apr 2010, 2:04 PM
Why adapter don't use smth like this:


(function($)
{
$.fn.toExt = function()
{
//console.log(this);
return Ext.get(this[0]);
}

var oldExtGet = Ext.get;
Ext.get = function(el)
{
if (typeof el.jquery != 'undefined')
return el.toExt();

return oldExtGet(el);
}
})(jQuery);
?

tryanDLS
15 Apr 2010, 3:28 PM
It would seem like a lot of overhead to wrap a DOM element with a jQuery object and then have to unwrap it build an Ext object around it. While jQuery $ and Ext.get both wrap DOM object, they are not equivalent.
Ext.get('tree') != $('#tree') // where tree is DOM element.

Doing that conversion back and forth on every operation would be expensive. The Ext object does pretty much the same thing as $, albeit with slighty different syntax. If you're really high on using the $ to reduce keystrokes, you could set $=Ext.get;

Koc
15 Apr 2010, 11:32 PM
I don't want override "$". There are too much differences with Ext.get and $ usage
http://matthiasschuetz.com/javascript-framework-matrix/en/dom-basics

Animal
15 Apr 2010, 11:54 PM
If you truly think that the term "css" indicates to future maintainers of your code (who may be violent psychopaths who know where you live) the intention of your code better than "setStyle", then you can very easily set that method to be equivalent.



Ext.CompositeElementLite.prototype.css = function() {
this.invoke("setStyle", arguments);
};

Animal
16 Apr 2010, 12:08 AM
Is that your site, http://matthiasschuetz.com/javascript-framework-matrix/en/dom-basics ?

That's very cool, kind of a rosetta stone for Ajax foundation libraries. I think a link to that from Ext's Learning page is needed, that will help out people with crossover.

Animal
16 Apr 2010, 12:15 AM
I FAQed it: http://www.extjs.com/learn/Ext_Getting_Started#What_are_the_ExtJS_equivalents_of_jQuery.2Fprototype.2FDojo.2Fmootools_primitives.3F

steffenk
16 Apr 2010, 2:55 AM
I don't think it's his site, as the author of the site is german but Koc seems to be russian.

You can't mix jquery and ExtJS. Using the adapter means that you can use jQuery or ExtJS side by side.
But in ExtJS method there is no way using jQuery functions.

Koc
16 Apr 2010, 4:24 AM
Is that your site, http://matthiasschuetz.com/javascript-framework-matrix/en/dom-basics ?

That's very cool, kind of a rosetta stone for Ajax foundation libraries. I think a link to that from Ext's Learning page is needed, that will help out people with crossover.

oh, no, I've just finded this site by Google :).

steffenk, yes, I'm from Ukraine.