|
1 | 1 | /*!
|
2 | 2 | * jQuery Form Plugin
|
3 |
| - * version: 3.18 (28-SEP-2012) |
| 3 | + * version: 3.22 (1-DEC-2012) |
4 | 4 | * @requires jQuery v1.5 or later
|
5 | 5 | *
|
6 | 6 | * Examples and documentation at: http://malsup.com/jquery/form/
|
@@ -172,7 +172,11 @@ $.fn.ajaxSubmit = function(options) {
|
172 | 172 | };
|
173 | 173 |
|
174 | 174 | // are there files to upload?
|
175 |
| - var fileInputs = $('input:file:enabled[value]', this); // [value] (issue #113) |
| 175 | + |
| 176 | + // [value] (issue #113), also see comment: |
| 177 | + // https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219 |
| 178 | + var fileInputs = $('input[type=file]:enabled[value!=""]', this); |
| 179 | + |
176 | 180 | var hasFileInputs = fileInputs.length > 0;
|
177 | 181 | var mp = 'multipart/form-data';
|
178 | 182 | var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
|
@@ -221,6 +225,8 @@ $.fn.ajaxSubmit = function(options) {
|
221 | 225 | var result = {};
|
222 | 226 | var i, part;
|
223 | 227 | for (i=0; i < len; i++) {
|
| 228 | + // #252; undo param space replacement |
| 229 | + serialized[i] = serialized[i].replace(/\+/g,' '); |
224 | 230 | part = serialized[i].split('=');
|
225 | 231 | result[decodeURIComponent(part[0])] = decodeURIComponent(part[1]);
|
226 | 232 | }
|
@@ -286,7 +292,7 @@ $.fn.ajaxSubmit = function(options) {
|
286 | 292 | var useProp = !!$.fn.prop;
|
287 | 293 | var deferred = $.Deferred();
|
288 | 294 |
|
289 |
| - if ($(':input[name=submit],:input[id=submit]', form).length) { |
| 295 | + if ($('[name=submit],[id=submit]', form).length) { |
290 | 296 | // if there is an input with a name or id of 'submit' then we won't be
|
291 | 297 | // able to invoke the submit fn on the form (at least not x-browser)
|
292 | 298 | alert('Error: Form elements must not have name or id of "submit".');
|
@@ -764,9 +770,9 @@ function captureSubmittingElement(e) {
|
764 | 770 | /*jshint validthis:true */
|
765 | 771 | var target = e.target;
|
766 | 772 | var $el = $(target);
|
767 |
| - if (!($el.is(":submit,input:image"))) { |
| 773 | + if (!($el.is("[type=submit],[type=image]"))) { |
768 | 774 | // is this a child element of the submit el? (ex: a span within a button)
|
769 |
| - var t = $el.closest(':submit'); |
| 775 | + var t = $el.closest('[type=submit]'); |
770 | 776 | if (t.length === 0) {
|
771 | 777 | return;
|
772 | 778 | }
|
@@ -924,19 +930,19 @@ $.fn.fieldSerialize = function(successful) {
|
924 | 930 | * <input name="C" type="radio" value="C2" />
|
925 | 931 | * </fieldset></form>
|
926 | 932 | *
|
927 |
| - * var v = $(':text').fieldValue(); |
| 933 | + * var v = $('input[type=text]').fieldValue(); |
928 | 934 | * // if no values are entered into the text inputs
|
929 | 935 | * v == ['','']
|
930 | 936 | * // if values entered into the text inputs are 'foo' and 'bar'
|
931 | 937 | * v == ['foo','bar']
|
932 | 938 | *
|
933 |
| - * var v = $(':checkbox').fieldValue(); |
| 939 | + * var v = $('input[type=checkbox]').fieldValue(); |
934 | 940 | * // if neither checkbox is checked
|
935 | 941 | * v === undefined
|
936 | 942 | * // if both checkboxes are checked
|
937 | 943 | * v == ['B1', 'B2']
|
938 | 944 | *
|
939 |
| - * var v = $(':radio').fieldValue(); |
| 945 | + * var v = $('input[type=radio]').fieldValue(); |
940 | 946 | * // if neither radio is checked
|
941 | 947 | * v === undefined
|
942 | 948 | * // if first radio is checked
|
@@ -1037,6 +1043,13 @@ $.fn.clearFields = $.fn.clearInputs = function(includeHidden) {
|
1037 | 1043 | else if (tag == 'select') {
|
1038 | 1044 | this.selectedIndex = -1;
|
1039 | 1045 | }
|
| 1046 | + else if (t == "file") { |
| 1047 | + if ($.browser.msie) { |
| 1048 | + $(this).replaceWith($(this).clone()); |
| 1049 | + } else { |
| 1050 | + $(this).val(''); |
| 1051 | + } |
| 1052 | + } |
1040 | 1053 | else if (includeHidden) {
|
1041 | 1054 | // includeHidden can be the value true, or it can be a selector string
|
1042 | 1055 | // indicating a special test; for example:
|
|
0 commit comments