Raxan JavaScript Object Quick Reference

The Raxan JavaScript Object provides a reference to the methods and properties used by the Raxan Framework.

<script src="raxan/startup.js" type="text/javascript">

        alert('The page is now ready for DOM manipulation');

Dynamic loading of Style Sheets and Javascript Libraries

At times, you only want to load a portion of your scripts and/or style sheets when the user completes a specific task. This makes it easier on the loading time required at startup and gives you the option of breaking up your very large scripts into smaller and more manageable script files.

Raxan provides two API functions to dynamic load of Javascript and CSS files from the within "ui/javascript" and "ui/css" folders or from any other folder location.

To use the include() function, simply pass the name and path to the script file without the .js extension if the file is located inside the plugins folder. For example:

<script type="text/javascript">
    // where namespace is a sub-folder within the plugins folder

For script files that are not located inside the ui/javascript folder, use the following syntax:

<script type="text/javascript">
    Raxan.include('path/to/folder/myscript.js', true);

Note here that the extension of the file must be included and the second parameter set to true.

To receive notification after the file has been loaded you can pass a callback function as the third parameter:

<script type="text/javascript">
    Raxan.include('path/to/folder/myscript.js', true, function(){
        alert('File loaded successfully');

When you want to dynamically load a stylesheet, the css() function must be used. The concept is similar to that of the include() function with the exception that stylesheets are loaded from the "ui/css" folder and there is no support for a callback function:

<script type="text/javascript">

    // for other stylesheets
    Raxan.css('path/to/folder/stylesheet.css', true);

RJO Methods & Properties

Methods/Events Description Notes
version Return the version number of the framework alert(html.version);
path Path to framework files. This will be detected by default.

To manually set the library path use:

html.path = './raxan-changes';

csspath Path to Raxan sylesheets. This will be detected by default.

To manually set the css path use:

html.csspath = './mystyles';

pluginpath Path to Raxan plugins. This will be detected by default.

To manually set the plugins path path use:

html.pluginpath = './myplugins';

mainScript Returns the name of the main startup or code-behind script. If multiple startup scripts were specified then this property will return an array. alert(html.mainScript)

Bind the event of an html element to a function.

  • css - Element selector
  • evt - Name of event
  • fn - Callback function

                Raxan.bind("#btnsave", "click", function(){
                    alert("You have clicked me");

Dynamically load a stylesheet from the server.

  • src - Stylesheet URL.
  • extrn - Set to true when loadig styles that are not located inside styles folder.

                // for other stylesheets
Raxan.include("path/to/folder/stylesheet.css", true);

Dynamically load a Javascript from the server.

  • src - Javscript URL.
  • extrn - Set to true when loadig styles that are not located inside plugins folder.
  • fn - Calback function to receive notification after the file has loaded.

                Raxan.include("path/to/folder/myscript.js", true);
                Raxan.include("path/to/folder/myscript.js", true, function(){
                    alert("File loaded successfully");
urlparams() Returns an array containing url parameters passed to the page. var url = Raxan.urlparams();

filename() Returns the web page file

post(url, data) Post data to the server.
  • url - URL to post data.
  • data - hash array containing data to be sent to the web server.

                var data = {
                    name2: "value2"
                // send data to server
log(txt) Log text to window.console or display in status bar. The window.console is used if Firebug is enabled.

Client-Server Methods
createConduit(name, option) See Asynchronous Data Conduits for more information.
dispatchEvent(type,value,fn) See Client-Server Introduction for more information.
getVar(name) See Client-Server Introduction for more information.
Events & Callbacks
ready(fn) Bind a function to the ready event. This event is triggered when the DOM has been loaded and can be manipulated.

                    alert("The DOM is ready");
load(fn) Bind a function to the browser's onload event.
unload(fn) Bind a function to the browser's unload event.
togglePreloader(fn) Bind a function to Raxan's preloader event. This event is triggered before and after a client-server request.

                    if (mode=='on') $('#loader').show();
                    else if (mode=='off') {
                        if (e.serverResult) alert(e.serverResult); // result returned from server
error(fn) Bind a function to Raxan's error event. This event is only triggered whenever an unhandled client/server error occurs.

                    if (httpCode==404) alert('File not found: ' + errText);
                    else alert('Error: ' + errText);
                    return true; // let the library know that the error was handled