Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Global Changed event handler

    Hi. We'd really like to have a single global event handler for our changed events, as far as it applies to the formitem class.What we'd actually like is that the global handler executes and then when its completed the specific handler for that formitem executes (if one exists).

    I've been playing around with this for a few days. I'm not sure how I'd go about subclasses FormItem (or subclasses all of the subclasses of formitem actually) because the DynamicForm class creates FormItems naturally and I don't think I can tell it to us my subclass instead.

    I've tried iterating over the formItems at dynamicform creation time and swapping out the changed handler like so:

    Code:
    isc.DynamicForm.addClassMethods({
    baseCreate:isc.DynamicForm.create,
    create:function(A,B,C,D,E,F,G,H,I,J,K,L,M,N)
    {
    	var inst = this.baseCreate(A,B,C,D,E,F,G,H,I,J,K,L,M,N);	
    	
    
    		for(var x = 0; x < inst.fields.length; x++)
    		{
    
    
    		if(inst.fields[x].changed != null)
    		{
    			Log.logInfo("Changed: " + inst.fields[x].changed + " " + inst.fields[x].change);
    			inst.fields[x].baseChanged = inst.fields[x].changed;
    			Log.logInfo("Moved: " + inst.fields[x].baseChanged);
    			inst.fields[x].changed = "globalOnChanged(form, item, value)";
    			Log.logInfo("new Changed: " +inst.fields[x].changed);
    		}
    		
    		}		
    	
    	return inst;
    
    }
    });
    which basically just puts the current Changed event handler into temporary storage and will try to execute the global handler first. The global handler had been set to call the specific changed handler when its done.


    The log messages confirm that the functions are indeed being swapped but when a changed event occurs, the specific changed event handler for that formitem is called not the global.

    Can anyone help me?
    Thanks in advance

    #2
    You may be able to use dynamicForm.itemChange event. This event is fired any time an item is about to change rather than after it changes.

    Comment


      #3
      That worked well, thank you.

      I would have rather not overriden a function but since change and changed seem superior to this function anyway, it turned out fine.

      Thanks for the advice

      Comment

      Working...
      X