Skip to content
Browse files

Merge pull request #151 from kossnocorp/zepto

---

This pull request related to #139
  • Loading branch information...
2 parents b563f8b + 8e412bf commit 0d2eb8ac655b3b0b4d6d9d81cf400266891b26d7 @madrobby committed May 2, 2011
Showing with 24 additions and 3 deletions.
  1. +2 −0 README.rdoc
  2. +9 −0 src/zepto.js
  3. +13 −3 test/zepto.html
View
2 README.rdoc
@@ -102,6 +102,8 @@ Context and .find calls are equivalent:
die([, type[, function]]): remove live listener
trigger(type): triggers an event
+ submit(): trigger form submit event
+
== Non-jQuery functions
pluck(property):
View
9 src/zepto.js
@@ -252,6 +252,15 @@ var Zepto = (function() {
((when !== undefined && !when) || $(this).hasClass(name)) ?
$(this).removeClass(name) : $(this).addClass(name)
});
+ },
+ submit: function () {
+ return this.each(function () {
+ try {
+ // Submit first form element
+ this.submit();
+ return;
+ } catch(e) {};
+ });
}
};
View
16 test/zepto.html
@@ -137,6 +137,8 @@
<input type="text" id="BooleanInput" required />
+ <form id="some_form"></form>
+
<script>
function click(el){
@@ -1093,10 +1095,18 @@
var foo = false;
$(document).ready(function () { $(document).ready(function () { foo = true; }) });
t.assert(foo);
- }
-
-
+ },
+ testFormSubmit: function (t) {
+ // Test form submit action
+ var formSubmitted = false;
+ $('#some_form').get(0).submit = function (e) {
+ formSubmitted = true;
+ e.preventDefault();
+ };
+ $('#some_form').submit();
+ t.assert(formSubmitted);
+ }
});
</script>
</body>

0 comments on commit 0d2eb8a

Please sign in to comment.
Something went wrong with that request. Please try again.