jQuery.Controller.static.processors  attribute     

An object of {eventName : function} pairs that Controller uses to hook up events auto-magically. A processor function looks like:

jQuery.Controller.processors.
  myprocessor = function( el, event, selector, cb, controller ) {
     //el - the controller's element
     //event - the event (myprocessor)
     //selector - the left of the selector
     //cb - the function to call
     //controller - the binding controller
  };

This would bind anything like: "foo~3242 myprocessor".

The processor must return a function that when called, unbinds the event handler.

Controller already has processors for the following events:

  • change
  • click
  • contextmenu
  • dblclick
  • focusin
  • focusout
  • keydown
  • keyup
  • keypress
  • mousedown
  • mouseenter
  • mouseleave
  • mousemove
  • mouseout
  • mouseover
  • mouseup
  • reset
  • resize
  • scroll
  • select
  • submit

The following processors always listen on the window or document:

  • windowresize
  • windowscroll
  • load
  • unload
  • hashchange
  • ready

Which means anytime the window is resized, the following controller will listen to it:

$.Controller('Sized',{
  windowresize : function(){
    this.element.width(this.element.parent().width() / 2);
  }
});

$('.foo').sized();
© Jupiter IT - JavaScriptMVC Training and Support