Skip to content
keyang xiang edited this page Apr 1, 2012 · 1 revision

#Controller

##Introduction

In JQMVC, controllers define a set of methods that receive user actions such as: Click a Button, Start the App, Open an example etc. Controllers manipulate views and models.

##Development

To register a controller, it is convenient to use mvc.regCtl method:

	mvc.regCtl("controllerName",{
		prop1:"value",
		prop2:"value",
		
		method1:function(arg){
			this.prop1=arg.val;
			//implementation
		},
		method2:function(arg){
			//implementation
			mvc.view("myView").show();
		},
		UserClickRedButton:function(){
			
		}
	
	}); 

After a controller is registered, it is able to send messages to controller by using:

	mvc.ctl("controllerName").sendMSG("methodName",arguments); // Synchorous Call. Block.

Or it is able to send a non-blocking message through:

	mvc.ctl("controllerName").postMSG("methodName",arguments,callback); // Asynchorous Call. Non-Block.
Clone this wiki locally