Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed support for checkboxes

  • Loading branch information...
commit 5051789123b3878696927df4661f13bb1ebf815e 1 parent 44ed25f
@fgnass authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/aspects/relay.js
View
9 lib/aspects/relay.js
@@ -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;
Please sign in to comment.
Something went wrong with that request. Please try again.