Permalink
Browse files

docs(ajax): fixes constructor usage of elgg/Ajax

Fixes #9533
  • Loading branch information...
mrclay committed Apr 12, 2016
1 parent 73fe45f commit 07c7ce49538ae8b61b3c48cd1e5a8287dc777e5b
Showing with 10 additions and 4 deletions.
  1. +10 −4 docs/guides/ajax.rst
View
@@ -59,7 +59,8 @@ To execute it, use ``ajax.action('<action_name>', options)``:
.. code-block:: js
- var ajax = new require('elgg/Ajax')();
+ var Ajax = require('elgg/Ajax');
+ var ajax = new Ajax();
ajax.action('do_math', {
data: {
@@ -106,7 +107,8 @@ To fetch its output, use ``ajax.path('<url_path>', options)``.
.. code-block:: js
- var ajax = new require('elgg/Ajax')();
+ var Ajax = require('elgg/Ajax');
+ var ajax = new Ajax();
ajax.path('myplugin_time').done(function (output) {
alert(output.rfc2822);
@@ -152,7 +154,8 @@ To fetch the view, use ``ajax.view('<view_name>', options)``:
.. code-block:: js
- var ajax = new require('elgg/Ajax')();
+ var Ajax = require('elgg/Ajax');
+ var ajax = new Ajax();
ajax.view('myplugin/get_link', {
data: {
@@ -189,7 +192,8 @@ To fetch this using ``ajax.form('<action_name>', options)``.
.. code-block:: js
- var ajax = new require('elgg/Ajax')();
+ var Ajax = require('elgg/Ajax');
+ var ajax = new Ajax();
ajax.form('myplugin/add').done(function (output) {
$('.myplugin-form-container').html(output);
@@ -228,6 +232,8 @@ Let's say when the view ``foo`` is fetched, we want to also send the server some
var Ajax = require('elgg/Ajax');
var elgg = require('elgg');
+ var ajax = new Ajax();
+
elgg.register_hook_handler(Ajax.REQUEST_DATA_HOOK, 'view:foo', function (name, type, params, data) {
// send some data back
data.bar = 1;

0 comments on commit 07c7ce4

Please sign in to comment.