7

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
Robert Koritnik
  • 103,639
  • 52
  • 277
  • 404

1 Answers1

3

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
  • 40,390
  • 17
  • 88
  • 107
  • doesn't jQuery's extend() function only extend "element set" type and is not intended for extending any other object instances? – Robert Koritnik Sep 10 '09 at 13:54
  • 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 Sep 11 '09 at 09:58
  • 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 Sep 11 '09 at 12:37