Skip to content

Commit

Permalink
Try to explain things better in the documentation
Browse files Browse the repository at this point in the history
Explain some more about how things work and where sijax.js
is coming from, as suggested in GitHub issue #3.
  • Loading branch information
spantaleev committed May 22, 2012
1 parent a40327d commit ad3e014
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '0.3.0' version = '0.3.1'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '0.3.0' release = '0.3.1'


# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
Expand Down
25 changes: 16 additions & 9 deletions docs/index.rst
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ Configuration options
**Flask-Sijax** is configured via the standard Flask config API. **Flask-Sijax** is configured via the standard Flask config API.
Here are the available configuration options: Here are the available configuration options:


* **SIJAX_STATIC_PATH** - set this to the static path where you want the Sijax files to be located. * **SIJAX_STATIC_PATH** - the static path where you want the Sijax javascript files to be mirrored.


Flask-Sijax takes care of keeping the Sijax files up to date in this directory (even between version changes). Flask-Sijax takes care of keeping the Sijax javascript files ``sijax.js`` and ``json2.js``
The specified directory needs to be dedicated for Sijax static files. You should not put anything else in it. up to date in this directory (even between version changes).


Don't put anything else in that directory - it should be dedicated to Sijax for hosting the files.


* **SIJAX_JSON_URI** - the URI to load the ``json2.js`` static file from (in case it's needed).
* **SIJAX_JSON_URI** - the URI to load the ``json2.js`` static file from (if needed).


Sijax uses JSON to pass data between the browser and server. This means that browsers either need to support Sijax uses JSON to pass data between the browser and server. This means that browsers either need to support
JSON natively or get JSON support from the ``json2.js`` file. Such browsers include IE <= 7. JSON natively or get JSON support from the ``json2.js`` file. Such browsers include IE <= 7.
Expand Down Expand Up @@ -140,11 +142,16 @@ To learn more on ``obj_response`` and what it provides, see :class:`sijax.respon
Setting up the client (browser) Setting up the client (browser)
------------------------------- -------------------------------


The browser needs to talk to the server and that's done using `jQuery`_ (``jQuery.ajax``) and the Sijax javascript files. The browser needs to talk to the server and that's done using `jQuery`_ (``jQuery.ajax``)
This means that you'll have to load those on each page that needs to use Sijax. and the Sijax javascript file (``sijax.js``).
You'll have to load those on each page that needs to use Sijax.

The ``sijax.js`` file is part of the `Sijax`_ project, but can be mirrored to a directory
of your choosing if you use the ``SIJAX_STATIC_PATH`` configuration option (see above).
There is no need to download Sijax separately and extract the file from it manually.


After both files are loaded, you can put the javascript init code (``g.sijax.get_js()``) somewhere on the page. Once both files are loaded, you can put the javascript init code (``g.sijax.get_js()``) somewhere on the page.
That code is page-specific and needs to be executed, after the ``sijax.js`` file has loaded. That code is page-specific and needs to be executed after the ``sijax.js`` file has loaded.


Assuming you've used the above configuration here's the HTML markup you need to add to your template:: Assuming you've used the above configuration here's the HTML markup you need to add to your template::


Expand All @@ -160,7 +167,7 @@ You can then invoke a Sijax function using javascript like this::


Sijax.request('function_name', ['argument 1', 150, 'argument 3']); Sijax.request('function_name', ['argument 1', 150, 'argument 3']);


provided it has been defined and registered with Sijax:: provided the function has been defined and registered with Sijax on the server-side::


def function_name(obj_response, arg1, arg2, arg3): def function_name(obj_response, arg1, arg2, arg3):
obj_response.alert('You called the function successfully!') obj_response.alert('You called the function successfully!')
Expand Down

0 comments on commit ad3e014

Please sign in to comment.