Class: Group

This class is for grouping Classes or Events. The Event added to the Group will fire when all of the events of the items of the group are fired.

Синтаксис:

var myGroup = new Group(class[, arrays[, class2[, ... ]]]);

Аргументы:

Any number of Class instances, or arrays containing class instances.

Возвращает:

  • (object) A new Group instance.

Примеры:

var xhr1 = new Ajax('data.js', {evalScript: true});

var xhr2 = new Ajax('abstraction.js', {evalScript: true});
var xhr3 = new Ajax('template.js', {evalScript: true});

 
var group = new Group(xhr1, xhr2, xhr3);
group.addEvent('complete', function(){

    alert('All Scripts loaded');
});
 
xhr1.request();
xhr2.request();
xhr3.request();

Group Method: addEvent

Adds an Event to the stack of Events of the Class instances.

Синтаксис:

myGroup.addEvent(type, fn);

Аргументы:

  1. type - (string) The event name (e.g. 'complete') to add.
  2. fn - (function) The callback function to execute when all instances fired this event.

Возвращает:

  • (object) This Group instance.

Примеры:

var myElements = $('myForm').getElements('input, textarea, select');
myElements.addEvent('click', function(){

    alert('an individual click');
});
 
var myGroup = new Group(myElements);
myGroup.addEvent('click', function(){

    alert('all form elements clicked');
});

Смотрите также:


Эта документация распостраняется на правах Attribution-NonCommercial-ShareAlike 3.0 License.
Оригинал документации на английском.
© Linux.ria.ua, 2008-2024