Записи с темой: extjs (список заголовков)

Injecting Traits into Javascript Objects

Vi Veri Veniversum Vivus Vici
На блоге Ed Spencer в посте о его взглядах на микшины в старых версиях ExtJS дана ссылка на блог другого программиста и его статью Injecting Traits into Javasсript Objects. Спасаю ее здесь:

Duplication is the mother of all evil in programming. Remaining DRY at all costs should be your goal at all times. A pattern repeats itself one time and your code complexity goes up exponentially.

One great way to DRY up your code is via Traits. Traits are functional equivalent of base classes where you can collect most often used functions and inject these Traits into your objects. Here’s one simple way to do it in Javasсript (using extjs here):

  1. MyTrait = {
  2. xhr: function(config) { return Ext.Ajax.request(config) },
  3. submit: function(basic_form,config) {
  4. //perform some checks on config
  5. // and call basic_form.submit
  6. },
  7. //...add more utility functions
  8. }
  9. function MyGrid(config) {MyGrid.superclass.constructor.call(this,config)}
  10. Ext.extend(MyGrid, Ext.grid.GridPanel, MyTrait);

@темы: ExtJS


ExtJS add custom text to the fieldset label

Vi Veri Veniversum Vivus Vici
  1. var x = Ext.getCmp('ext-comp-1404').el;
  2. x.first().createChild({tag: 'span', html: ' (test message)'});

@темы: ExtJS, JavaScript

Small Coder Blog