Slide Model API

Purpose

Provides methods that manage the contents of the slides to be presented by the Slide View component. The presentation of slides is handled by a renderer that is responsible for turning the data into a DOM element which is then passed to the selected ui:slide-view element.

JavaScript

getSlideCount()

Returns the number of slides in the model.

getSlide(slide)

Returns the contents of the selected slide.

Parameter Description Type
slide The index of the slide to retrieve; must be between 0 (inclusive) and getSlideCount() (exclusive). int

Events

Whenever the contents of a slide changes, the model fires the cf2:slideChanged event. The following table lists its properties.

cf2:slideChanged
Property Description Type
target The slide model that has changed. Object
slide The slide that has changed. int
oldContent The old slide content. any
newContent The new slide content. any

Whenever the number of slides changes, the model fires the cf2:slideCountChanged event.

cf2:slideCountChanged
Property Description Type
target The slide model that has changed. Object
oldCount The old number of slides in the selected model. int
newCount The new number of slides in the selected model. int

Example

var DOMSlideModel = V$.Class.create();
DOMSlideModel.mixin(V$.cf2.EventTarget);
DOMSlideModel.methods({
  initialize: function() {
  },
  _bindToDOM: function(el) {
    if (this._bound) {
      throw "SlideModel already bound to DOM element";
    }
    this._el = V$E(el);
    this._bound = true;
    this._s = this._el.v_getChildren();
  },
  getSlideCount: function() {
    return this._s.length;
  },
  getSlide: function(i) {
    return this._s[i];
  }
});

Related topics