Hi guys, here is a class I have and want it to be chain-able. Look at the 
code sample first:

var myClass = new Class({
 _isRunning : false,
 Implements : [Options, Chain],

 options: {
 link : 'chain'
 },

 initialize : function(el, options) {
 this.setOptions(options);
 },

 start : function(opts) {
 if ( !this._checkChain() )
  return this;
 this._isRunning = true;

 if ( !someConditions ) {
  alert(this.$chain.length);
  return this;
 }
   /* Where the actual process begins... */
 },

 _checkChain : function() {
 if ( !this._isRunning )
 return true;
 switch ( this.options.link ) {
 case 'cancel' : this.cancel();
 return true;
 case 'chain' : this.chain(this.caller.pass(arguments, this));
   alert('link: '+this.options.link);
 return false;
 }
 return false;
 }
});

Now, the issue is, when 'someCondition' part doesn't break the actual 
process, the chain can be stored just fine, and the flag _isRunning turns 
to TRUE. However, when conditions doesn't match and the process returns 
THIS, the chain seems to be ignored.

The actual process includes chain check and callChain methods, but note the 
condition part, the length of chained functions is always 0 when the 
function breaks.

Why is this happening?

Reply via email to