Prevents a class from applying itself to an element that already has had the class applied.

Tutorial/Demo

Determines if the class has already been applied to the element.

Syntax

this.occlude(property, element)

Arguments

  1. property - (string) property name for instances of this class attached to the element via Element.Storage
  2. element - (mixed) an Element or the string id of an Element to test

Example

var Widget = new Class({
    Implements: [Class.Occlude],
    intialize: function(element){
        if (this.occlude('widget', element)) return this.occluded;
        //returns the instance already bound to the element and exits
    }
});

Note

See the two properties below for ideal usage.

The string used to bind the instance of the class to the element.

Example

var Widget = new Class({
    Implements: [Class.Occlude],
    property: 'widget',
    intialize: function(element){
        this.element = $(element);
        if (this.occlude()) return this.occluded;
        //returns the instance already bound to the element and exits
    }
});

Note

In the example above, because we have a this.element property and because we define the this.property property in the class, the method occlude doesn't require any arguments as it uses these by default.