diff --git a/CHANGES.md b/CHANGES.md
index beee19fa7..0284cc9cb 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -14,6 +14,7 @@ Features
- Added support for a push subsystem using reethinkdb and horizon.
That allows us to trigger an injection by sending a push_marker to all connected browsers.
(This is still in an evaluation state)
+- pat-forward: understand the trigger auto option
Fixes
~~~~~
diff --git a/src/pat/forward/documentation.md b/src/pat/forward/documentation.md
index 2ad85d7e5..f11e277ef 100644
--- a/src/pat/forward/documentation.md
+++ b/src/pat/forward/documentation.md
@@ -10,8 +10,17 @@ This pattern can be used to redirect a click on an element to one or more other
Submit
+If the trigger parameter is set to `auto`, the click event will be triggered
+immediately after the page is loaded.
+
+ Autosubmit form
+
+
### Option reference
| Property | Description | Default | Allowed Values | Type |
|------|------|-----|------|
-| selector | The element to which the click event should be forwarded. | | | CSS Selector |
+| `selector` | The element to which the click event should be forwarded. | | | CSS Selector |
+| `trigger` | When the forward action should be fired | `click` | `click|auto` | One of the mutually exclusive string values |
diff --git a/src/pat/forward/forward.js b/src/pat/forward/forward.js
index adcc98507..a179cf773 100644
--- a/src/pat/forward/forward.js
+++ b/src/pat/forward/forward.js
@@ -11,20 +11,24 @@ define([
var parser = new Parser("forward");
parser.addArgument("selector");
+ parser.addArgument("trigger", "click", ["click", "auto"]);
var _ = {
name: "forward",
trigger: ".pat-forward",
init: function($el, opts) {
- return $el.each(function() {
+ return $el.each(function () {
var $el = $(this),
- options = parser.parse($el, opts);
+ options = parser.parse($el, opts);
if (!options.selector)
- return;
+ return;
$el.on("click", null, options.selector, _._onClick);
+ if (options.trigger === "auto") {
+ $el.trigger("click");
+ }
});
},
@@ -39,4 +43,3 @@ define([
});
// vim: sw=4 expandtab
-
diff --git a/src/pat/forward/index.html b/src/pat/forward/index.html
index a99b31b43..f7a0b88c5 100644
--- a/src/pat/forward/index.html
+++ b/src/pat/forward/index.html
@@ -13,10 +13,16 @@
-
+
+
+