views:

699

answers:

1

ExtJS provides some great helper functions like:

  • Ext.extend()
  • Ext.apply()
  • Ext.namespace()

Are there any equivalents in jQuery? I know I could port all three to jQuery since I like them so much, but maybe I'm missing something that's already there. I would like to avoid mingling with prototypes myself if possible.

Endresult

  • Ext.apply(obj1, obj2) => $.extend(obj1, obj2)
  • Ext.extend(obj1, obj2) => $.extend(obj1.prototype, obj2)
  • Ext.ns(string) => custom implementation
+1  A: 

jQuery's extend function is like ExtJS's apply function in that it copies data members from the source to the destination. The others might be already made as plugins, but I don't know of any.

geowa4
doesn't jQuery's extend() function only extend "element set" type and is not intended for extending any other object instances?
Robert Koritnik
http://docs.jquery.com/Utilities/jQuery.extend#deeptargetobject1objectN
geowa4
great. I guess Ext.extend() can be used with the same jquery function just specifying type prototype instead of an instance. What about namespace?
Robert Koritnik
I think `extend` is the only one that jQuery supports out of the box. There might be plugins available for the other two, but I don't know of them. But as you said, you are willing to make them yourself and they aren't difficult.
geowa4