summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source/libraries
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-02-07 14:49:06 +0100
committerAndrey Andreev <narf@devilix.net>2014-02-07 14:49:06 +0100
commit46145faeb1ba56417af53b0aa545ba8437717da6 (patch)
tree7f884b79b09e69a0beb2f5266a3bac3203084d79 /user_guide_src/source/libraries
parentff6d1a80b75eb4303551be1f2708509757a85e50 (diff)
[ci skip] Some adjustments to the Javascript library docs
Diffstat (limited to 'user_guide_src/source/libraries')
-rw-r--r--user_guide_src/source/libraries/javascript.rst76
1 files changed, 48 insertions, 28 deletions
diff --git a/user_guide_src/source/libraries/javascript.rst b/user_guide_src/source/libraries/javascript.rst
index 393d4e321..bb901ead9 100644
--- a/user_guide_src/source/libraries/javascript.rst
+++ b/user_guide_src/source/libraries/javascript.rst
@@ -1,31 +1,51 @@
-.. note:: This driver is experimental. Its feature set and
- implementation may change in future releases.
-
################
Javascript Class
################
+.. note:: This driver is experimental. Its feature set and
+ implementation may change in future releases.
+
CodeIgniter provides a library to help you with certain common functions
that you may want to use with Javascript. Please note that CodeIgniter
does not require the jQuery library to run, and that any scripting
library will work equally well. The jQuery library is simply presented
as a convenience if you choose to use it.
+.. contents::
+ :local:
+
+.. raw:: html
+
+ <div class="custom-index container"></div>
+
+**************************
+Using the Javascript Class
+**************************
+
Initializing the Class
======================
To initialize the Javascript class manually in your controller
-constructor, use the $this->load->library function. Currently, the only
-available library is jQuery, which will automatically be loaded like
-this::
+constructor, use the ``$this->load->library()`` method. Currently,
+the only available library is jQuery, which will automatically be
+loaded like this::
$this->load->library('javascript');
-The Javascript class also accepts parameters, js_library_driver
-(string) default 'jquery' and autoload (bool) default TRUE. You may
-override the defaults if you wish by sending an associative array::
+The Javascript class also accepts parameters:
+
+- js_library_driver (string) *default: 'jquery'*
+- autoload (bool) *default: TRUE*
- $this->load->library('javascript', array('js_library_driver' => 'scripto', 'autoload' => FALSE));
+You may override the defaults by sending an associative array::
+
+ $this->load->library(
+ 'javascript',
+ array(
+ 'js_library_driver' => 'scripto',
+ 'autoload' => FALSE
+ )
+ );
Again, presently only 'jquery' is available. You may wish to set
autoload to FALSE, though, if you do not want the jQuery library to
@@ -34,7 +54,8 @@ is useful if you are loading it from a location outside of CodeIgniter,
or already have the script tag in your markup.
Once loaded, the jQuery library object will be available using:
-$this->javascript
+
+ $this->javascript
Setup and Configuration
=======================
@@ -47,8 +68,8 @@ application.
As Javascript is a client side language, the library must be able to
write content into your final output. This generally means a view.
-You'll need to include the following variables in the <head> sections of
-your output.
+You'll need to include the following variables in the ``<head>``
+sections of your output.
::
@@ -56,17 +77,17 @@ your output.
<?php echo $script_head;?>
-$library_src, is where the actual library file will be loaded, as well
-as any subsequent plugin script calls; $script_head is where specific
-events, functions and other commands will be rendered.
+``$library_src``, is where the actual library file will be loaded, as
+well as any subsequent plugin script calls; $script_head is where
+specific events, functions and other commands will be rendered.
Set the path to the librarys with config items
----------------------------------------------
There are some configuration items in Javascript library. These can
-either be set in application/config.php, within its own
-config/javascript.php file, or within any controller usings the
-set_item() function.
+either be set in *application/config.php*, within its own
+*config/javascript.php* file, or within any controller usings the
+``set_item()`` function.
An image to be used as an "ajax loader", or progress indicator. Without
one, the simple text message of "loading" will appear when Ajax calls
@@ -84,7 +105,7 @@ The jQuery Class
================
To initialize the jQuery class manually in your controller constructor,
-use the $this->load->library function::
+use the ``$this->load->library()`` method::
$this->load->library('javascript/jquery');
@@ -96,30 +117,29 @@ library as follows::
$this->load->library('javascript/jquery', FALSE);
Once loaded, the jQuery library object will be available using:
-$this->jquery
+
+ $this->jquery
jQuery Events
=============
Events are set using the following syntax.
-
::
$this->jquery->event('element_path', code_to_run());
-
In the above example:
- "event" is any of blur, change, click, dblclick, error, focus, hover,
keydown, keyup, load, mousedown, mouseup, mouseover, mouseup, resize,
scroll, or unload.
-- "element_path" is any valid `jQuery
- selector <http://docs.jquery.com/Selectors>`_. Due to jQuery's unique
+- "element_path" is any valid `jQuery selector
+ <http://docs.jquery.com/Selectors>`_. Due to jQuery's unique
selector syntax, this is usually an element id, or CSS selector. For
- example "#notice_area" would effect <div id="notice_area">, and
+ example "#notice_area" would effect ``<div id="notice_area">``, and
"#content a.notice" would effect all anchors with a class of "notice"
in the div with id "content".
-- "code_to_run()" is script your write yourself, or an action such as
+- "``code_to_run()``" is script your write yourself, or an action such as
an effect from the jQuery library below.
Effects
@@ -298,4 +318,4 @@ description to come
calendar()
----------
-description to come
+description to come \ No newline at end of file