app/assets/javascripts/jqr-helpers.js in jqr-helpers-1.0.66 vs app/assets/javascripts/jqr-helpers.js in jqr-helpers-1.0.67
- old
+ new
@@ -497,34 +497,43 @@
$.each(dataAttrs, function(index, val) {
dataMap[val] = element.data(val);
element.removeAttr('data-' + val);
});
element.removeClass('ujs-ajax');
- $(this).find('input, select').data(dataMap).change(function() {
- // unchecked checkboxes would not be included. We'll replace it
- // with a checked one and value 0.
- $('body').remove('.jqr-hidden-checkbox');
- if ($(this).is(':checkbox:not(:checked)')) {
- $(this).uniqueId();
- element = $(this).clone();
- element.attr('id', '');
- element.data($(this).data());
- element.data('real-element', $(this).attr('id'));
- element.prop('value', '0');
- element.prop('checked', true);
- element.hide();
- element.addClass('jqr-hidden-checkbox').addClass('ujs-ajax');
- element.attr('data-remote', true);
- $('body').append(element);
- $.rails.handleRemote(element);
- }
- else {
- // Rails checks the attribute, not the data
- $(this).attr('data-remote', true).addClass('ujs-ajax');
- $.rails.handleRemote($(this));
- $(this).removeAttr('data-remote');
- }
- });
+ var hidden = $(this).find('[type=hidden]');
+ $(this).find('input, select').not('[type=hidden]').data(dataMap).
+ change(function() {
+ var params = hidden.map(function() {
+ return $(this).attr('name') + '=' +
+ encodeURIComponent($(this).val());
+ });
+ params = $.makeArray(params).join('&');
+ // unchecked checkboxes would not be included. We'll replace it
+ // with a checked one and value 0.
+ $('body').remove('.jqr-hidden-checkbox');
+ if ($(this).is(':checkbox:not(:checked)')) {
+ $(this).uniqueId();
+ element = $(this).clone();
+ element.attr('id', '');
+ element.data($(this).data());
+ element.data('real-element', $(this).attr('id'));
+ element.prop('value', '0');
+ element.prop('checked', true);
+ element.hide();
+ element.addClass('jqr-hidden-checkbox').addClass('ujs-ajax');
+ element.attr('data-remote', true);
+ $('body').append(element);
+ $(element).data('params', params);
+ $.rails.handleRemote(element);
+ }
+ else {
+ // Rails checks the attribute, not the data
+ $(this).attr('data-remote', true).addClass('ujs-ajax');
+ $(this).data('params', params);
+ $.rails.handleRemote($(this));
+ $(this).removeAttr('data-remote');
+ }
+ });
});
$(event.target).trigger('jqr.afterload');
}
$(function() {