Permalink
Browse files

Fixed support for checkboxes

  • Loading branch information...
1 parent 44ed25f commit 5051789123b3878696927df4661f13bb1ebf815e @fgnass committed Nov 18, 2011
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/aspects/relay.js
View
@@ -21,11 +21,11 @@ exports.apply = function($, window, document) {
$.fn.liveUpdate = function() {
this.client('live', 'change', function(ev) {
- var val = this.checked === undefined ? this.value : this.checked;
- $.sendEvent($.extend({}, ev, {type: 'update', newValue: val}));
+ var prop = (this.type == 'radio' || this.type == 'checkbox') ? 'checked' : 'value';
+ $.sendEvent($.extend({}, ev, {type: 'update', which: prop, newValue: this[prop]}));
});
this.live('update', function(ev) {
- this[this.checked === undefined ? 'value':'checked'] = ev.newValue;
+ this[ev.which] = ev.newValue;
$(this).trigger('change');
});
return this;
@@ -100,6 +100,9 @@ exports.client = function() {
}
$.sendEvent = function(ev) {
+ if (typeof ev == 'string') {
+ ev = {type: ev, target: document};
+ }
if (!ev.sent) {
var msg = flatten(ev);
msg.targetId = ev.target.id;

0 comments on commit 5051789

Please sign in to comment.