setInterval()

The same as window.setInterval() except that the supplied method is bound to the calling behavior object.

Syntax

behavior.setInterval(method [, delay [, arg1, arg2, ..., argN]]);

The method argument may also be a string identifying the method by name.

If the delay argument is not supplied then it defaults to 1 (milliseconds).

Arguments supplied after the delay argument are passed to the bound method.

Example

var mybehavior = jsb.behavior.extend({
  onfocus: function(element) {
    this._timer = this.setInterval(this.watchState, 50, element);
  },

  onblur: function(element) {
    clearInterval(this._timer);
    delete this._timer;
  },

  watchState: function(element) {
    if (!this.isValid(element)) {
      this.showWarning(element);
    }
  }
});

Notes

There is no jsb-equivalent clearInterval() method. Instead, you should use the global clearInterval() method.

See Also