DownloadJaxon 3.x :: Quick start
Register a single class
jaxon()->register(Jaxon::CALLABLE_CLASS, 'HelloWorld');
Register all classes in a directory
jaxon()->register(Jaxon::CALLABLE_DIR, '/full/path/to/dir');
Register all classes in a namespace
jaxon()->register(Jaxon::CALLABLE_DIR, '/full/path/to/dir', [
'namespace' => '\Path\To\Namespace',
]);
Register a function
jaxon()->register(Jaxon::CALLABLE_FUNCTION, 'sayHello');
Register a method as a function
// The corresponding javascript function name is 'setColor'
jaxon()->register(Jaxon::CALLABLE_FUNCTION, 'setColor', [
'class' => 'HelloWorld',
]);
Register a method as a function with an alias
// The corresponding javascript function name is 'helloWorld'
jaxon()->register(Jaxon::CALLABLE_FUNCTION, 'sayHello', [
'class' => 'HelloWorld',
'alias' => 'helloWorld',
]);
Call a registered class
<button onclick="<?php echo rq('HelloWorld')->call('sayHello') ?>" >Click Me</button>
Call a registered class with a parameter
<button onclick="<?php echo rq('HelloWorld')->call('sayHello', 0) ?>" >Click Me</button>
<button onclick="<?php echo rq('HelloWorld')->call('setColor', pr()->select('color')) ?>" >Click Me</button>
Call a registered function
<button onclick="<?php echo rq()->call('sayHello') ?>" >Click Me</button>
|