Going to go through a quick walk through of how to use a hacked together version of my old jquery library with solar. You can find the class source files Here
First thing we need to do is make sure that jquery is available to all our controllers, I do this by extending the Solar_Controller_Page and using that for my controllers
<?php
abstract class Jquery_App_Base extends Solar_Controller_Page {
// convenience method to add the callbacks needed
public function add_Jquery_Callback($callback) {
$this->_jquery_callbacks[] = array(get_class($this),$callback);
}
// Register the callbacks and process the queries
public function actionJquery() {
$config['default_callback_class'] = 'Jquery_App_Member';
$handler = new Jquery_App_Jquery($config);
foreach($this->_jquery_callbacks as $callback) {
$handler->registerCallback($callback);
}
$handler->processIncoming();
exit();
}
}
?>Now any controller can use the url "/controller/jquery/" to make jquery requests, the controller just has to register some functions within its class.
<?php
class Jquery_App_Member extends Jquery_App_Base {
// register our callback functions for use by jquery
public function __construct($config = null) {
parent::__construct($config);
// If no array is passed we assume reference to functions in the current class
$this->add_Jquery_Callback('getarray');
$this->add_Jquery_Callback('simplehtml');
$this->add_Jquery_Callback('jqueryeffects');
}
static function getarray() {
return array('a' => 1, 'b' => 2);
}
static function simplehtml($params) {
return '<B>Injected HTML'.$params.'</B>';
}
static function jqueryeffects() {
$responseObject = Zerg_App_Jquery_Response::getInstance();
$attribs = array();
$attribs['class'] = 'large';
$responseObject->attr($attribs);
$responseObject->show();
$responseObject->addClass('green');
$responseObject->Script('alert("Hello")');
}
}
?>The above code mimics my old examples which you can see http://www.cyberlot.net/demos/jqpie/test.html the only changes to the html would be the urls.. instead of handle.php you would use /member/jquery/

