Views

From ProtoScript

Jump to: navigation, search

Contents

YUI:SetClass Behavior

Sets a CSS style class. addClass (or it's equivalent styleClass) defines the style class to use.

A common technique is to use style classes to change portions of an interface by swapping out style classes.

Example

$proto('#avatar', {
  Click: {
    onClick: {
      SetClass: {
        styleClass: 'selected',
      }
    }  
  }
});

When the image (id=avatar) is clicked, set the class name to the 'selected' style class.

Attributes

Name Description Default Valid Values Example
target Selected element or elements to attach a click event to. If no value supplied, uses the last targeted element. If value is supplied, use the element(s) selected by the target instead. See Element Scope Inherits parent target String value denoting an interface element. target: '#avatar'
styleClass Name of CSS style class to use none any valid CSS class name addClass: 'hovered-over'

Callbacks

Name Description
onSetClass The callback corresponding to this behavior. Fired when behavior completes.

Demo

See SetClass Demo