You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2013/03/15 01:04:23 UTC

git commit: TAP5-2087: Handle checkboxes correctly in Ajax form submissions

Updated Branches:
  refs/heads/master 8c7d13299 -> dc64b55ed


TAP5-2087: Handle checkboxes correctly in Ajax form submissions


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/dc64b55e
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/dc64b55e
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/dc64b55e

Branch: refs/heads/master
Commit: dc64b55edc2ee9fd82d668fd7c0df1a886760160
Parents: 8c7d132
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu Mar 14 17:04:17 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu Mar 14 17:04:17 2013 -0700

----------------------------------------------------------------------
 .../META-INF/modules/t5/core/forms.coffee          |    4 +++-
 .../org/apache/tapestry5/t5-core-dom-jquery.coffee |    4 ++++
 .../apache/tapestry5/t5-core-dom-prototype.coffee  |    6 +++++-
 3 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dc64b55e/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee
index c0aa661..dc671f7 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee
@@ -73,6 +73,8 @@ define ["./events", "./dom", "./builder", "_"],
           # is handled by keeping a hidden field active with the data Tapestry needs
           # on the server.
           return if type is "file" || type is "submit"
+          
+          return if type is "checkbox" && field.checked() is false
 
           value = field.value()
 
@@ -165,4 +167,4 @@ define ["./events", "./dom", "./builder", "_"],
       # Sets a flag on the form to indicate that client-side validation should be bypassed.
       # This is typically associated with submit buttons that "cancel" the form.
       skipValidation: (form) ->
-        form.meta SKIP_VALIDATION, true
\ No newline at end of file
+        form.meta SKIP_VALIDATION, true

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dc64b55e/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee b/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee
index f85f027..033fa7e 100644
--- a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee
+++ b/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee
@@ -331,6 +331,10 @@ define ["_", "./utils", "jquery"], (_, utils, $) ->
         @$.val newValue
 
       return current
+      
+    # Returns true if a checkbox is checked
+    checked: ->
+      return @$.is(':checked')
 
     # Stores or retrieves meta-data on the element. With one parameter, the current value for the name
     # is returned (or undefined). With two parameters, the meta-data is updated and the previous value returned.

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dc64b55e/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee b/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee
index d55e276..0752843 100644
--- a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee
+++ b/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee
@@ -375,6 +375,10 @@ define ["_", "./utils", "prototype"], (_, utils) ->
         @element.setValue newValue
 
       return current
+      
+    # Returns true if a checkbox is checked
+    checked: ->
+      return @element.checked
 
     # Stores or retrieves meta-data on the element. With one parameter, the current value for the name
     # is returned (or undefined). With two parameters, the meta-data is updated and the previous value returned.
@@ -547,4 +551,4 @@ define ["_", "./utils", "prototype"], (_, utils) ->
     # Returns a wrapped version of the document.body element. Because all Tapestry JavaScript occurs
     # inside a block at the end of the document, inside the `<body`> element, it is assumed that
     # it is always safe to get the body.
-    body: -> wrapElement document.body
\ No newline at end of file
+    body: -> wrapElement document.body