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">
Raxan.include('jquery');
Raxan.ready(function(){
alert('The page is now ready for DOM manipulation');
});
</script>
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">
Raxan.include('jquery');
Raxan.include('namespace/myscript');
// where namespace is a sub-folder within the plugins folder
</script>
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);
</script>
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');
});
</script>
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">
Raxan.css('master');
Raxan.css('name-of-theme/theme');
// for other stylesheets
Raxan.css('path/to/folder/stylesheet.css', true);
</script>
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) |
Methods | ||
bind(css,evt,fn) |
Bind the event of an html element to a function.
|
|
|
||
css(src,extrn) |
Dynamically load a stylesheet from the server.
|
|
|
||
include(src,extrn,fn) |
Dynamically load a Javascript from the server.
|
|
|
||
urlparams() | Returns an array containing url parameters passed to the page. | var url = Raxan.urlparams(); alert(url['name']); |
filename() | Returns the web page file |
alert(Raxan.filename()); |
post(url, data) |
Post data to the 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. |
|
|
||
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. | |
|
||
error(fn) | Bind a function to Raxan's error event. This event is only triggered whenever an unhandled client/server error occurs. | |
|
||