]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Update abide.md
authorBrian Tan <briantan888@users.noreply.github.com>
Wed, 30 Dec 2015 17:54:25 +0000 (12:54 -0500)
committerBrian Tan <briantan888@users.noreply.github.com>
Wed, 30 Dec 2015 17:54:25 +0000 (12:54 -0500)
Provide example for form and element event listener

docs/pages/abide.md

index bcf55260289a27cc19845d301468b851457f8227..65eb96fdf118fd323595103930df1127a98c1cfa 100644 (file)
@@ -156,3 +156,25 @@ These input types create a text field: `text`, `date`, `datetime`, `datetime-loc
   </label>
 </form>
 ```
+## Event Listener
+```javascript
+$(document)
+  .bind("invalid.zf.abide", function(ev,elem) {
+    console.log("Field "+ev.target.id+" is invalid");
+  })
+  .bind("valid.zf.abide", function(ev,elem) {
+    console.log("Field "+elem.attr('name')+" is valid");
+  })
+  .bind("forminvalid.zf.abide", function(ev,form) {
+    console.log("Form "+ev.target.id+" is invalid");
+  })
+  .bind("formvalid.zf.abide", function(ev,form) {
+    console.log("Form "+form.attr('id')+" is invalid");
+    // ajax post form
+  })
+  .bind("submit", function(ev) {
+    ev.preventDefault();
+    console.log("Submit for form "+ev.target.id+" intercepted");
+    return false;
+  });
+  ```