Rich Ajax Application Framework

Global Functions

In addition to extending the RaxanWebPage class, there are four other globally accessible functions that are available to developers. These functions are wrappers or shortcuts to commonly used objects or methods. Calling this method will automatically create an instance of the RaxanWebPage class if a Page Controller was not found.

P() - This function provides a reference the default page controller, which is normally the first instance of the RaxanWebPage class.

<?php
    P()->append('Hi there!'); 
?>

C() - This provides a reference to the RaxanClientExtension class, which is used to generate and execute client-side action scripts. These action scripts are normally jQuery commands that are executed within the client's browser. Calling this method will automatically create an instance of the RaxanClientExtension class and load the Raxan startup and jQuery libraries.

<?php
    C('#box')->fadeOut(); 
?>

_fn() - Generates a client-side function and returns a reference to the function, which can then be passed to other action script commands. For Example:

<?php
    $cb = _fn('alert("Hello")'); 
    C('body')->click($cb);
?>

_var() - Generates a client-side JavaScript variable and returns a reference to the variable, which can then be passed to other action script commands

<?php
    $v = _var(array(1,2,3,4)); 
    C()->alert($v);
?>

_event() - Generates a client-side function that's used to trigger a server-side event and returns a reference the function, which can be passed to other action script commands.

<?php

    require_once('raxan/pdi/autostart.php');

    class NewPage extends RaxanWebPage {

        protected function _load() {
            if (!$this->isPostback)
                C()->confirm("Are you sure you want to continue?",_event('ok'),_event('cancel'));

            // register the 'ok' and 'cancel' page events
            $this->registerEvent('ok', '.okShow');
            $this->registerEvent('cancel', '.cancelShow');

        }

        protected function okShow($e){
            $this->content('Welcome to the Online Demo...');
        }

        protected function cancelShow($e){
            $this->content('Goodbye!');
        }

    }

?>

Note: For more information about the above global functions see the RaxanWebPage class reference.