Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

keep in sync when original checkbox's value changes. Fixes #48

  • Loading branch information...
commit 523468810a4fb7bd1618b62bf64fc0893eaa72b3 1 parent 753b119
Dmytrii Nagirniak authored
8 coffee/iphone-style-checkboxes.coffee
@@ -119,7 +119,7 @@ class iOSCheckbox
119 119 iOSCheckbox.dragging = null
120 120 @didChange()
121 121
122   - refresh: -> @didChange()
  122 + refresh: -> @didChange() #TODO: Verify - this might fire event unnecessarily
123 123
124 124 didChange: ->
125 125 @onChange?(@elem, @elem.prop('checked'))
@@ -148,6 +148,10 @@ class iOSCheckbox
148 148 $(document).unbind 'mousemove touchmove', localMouseMove
149 149 $(document).unbind 'mouseup touchend', localMouseUp
150 150
  151 + # The original checkbox value might be changed by clickig on the associated label or other means
  152 + # To make sure we are in sync:
  153 + @elem.change -> self.refresh()
  154 +
151 155 # A mousedown anywhere in the control will start tracking for dragging
152 156 @container.bind 'mousedown touchstart', (event) ->
153 157 self.onMouseDown.apply(self, arguments)
@@ -262,4 +266,4 @@ $.fn.iOSCheckbox = (options={}) ->
262 266 dataName: 'iOSCheckbox'
263 267 })
264 268
265   - this.iphoneStyle(opts)
  269 + this.iphoneStyle(opts)
4 compile
... ... @@ -0,0 +1,4 @@
  1 +coffee -o jquery -c coffee/iphone-style-checkboxes.coffee
  2 +pushd rails
  3 +rake update
  4 +popd
3  jquery/iphone-style-checkboxes.js
@@ -157,6 +157,9 @@
157 157 $(document).unbind('mousemove touchmove', localMouseMove);
158 158 return $(document).unbind('mouseup touchend', localMouseUp);
159 159 };
  160 + this.elem.change(function() {
  161 + return self.refresh();
  162 + });
160 163 return this.container.bind('mousedown touchstart', function(event) {
161 164 self.onMouseDown.apply(self, arguments);
162 165 $(document).bind('mousemove touchmove', localMouseMove);
3  rails/vendor/assets/javascripts/ios-checkboxes.js
@@ -159,6 +159,9 @@
159 159 $(document).unbind('mousemove touchmove', localMouseMove);
160 160 return $(document).unbind('mouseup touchend', localMouseUp);
161 161 };
  162 + this.elem.change(function() {
  163 + return self.refresh();
  164 + });
162 165 return this.container.bind('mousedown touchstart', function(event) {
163 166 self.onMouseDown.apply(self, arguments);
164 167 $(document).bind('mousemove touchmove', localMouseMove);

0 comments on commit 5234688

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