Skip to content

Commit 098965f

Browse files
committed
Update jquery.custom.forms-0.5.js
I change $(element).children('option[value="'+element.get(0).value+'"]').html() with $(element).find('option:selected').html() so it work with selects with optiongroups.
1 parent d19e4c7 commit 098965f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

jquery.custom.forms-0.5.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
});
4747

4848
$(document).bind('changeSelectValue', function(ev, element, fakeSelect) {
49-
var optionName = $(element).children('option[value="'+element.get(0).value+'"]').html();
49+
//var optionName = $(element).children('option[value="'+element.get(0).value+'"]').html();
50+
var optionName = $(element).find('option:selected').html();
5051
fakeSelect.html(optionName);
5152
});
5253
},
@@ -185,7 +186,8 @@
185186
},
186187

187188
createFakeElement: function(element, type) {
188-
var value = (type == 'select') ? $(element).children('option[value="'+element.get(0).value+'"]').html() : '';
189+
//var value = (type == 'select') ? $(element).children('option[value="'+element.get(0).value+'"]').html() : '';
190+
var value = (type == 'select') ? $(element).find('option:selected').html() : '';
189191
var disabled = element.attr('disabled') !== undefined
190192

191193
var fakeElement = $('<span class="'+ this.setClass(type) +'">'+ value +'</span>');
@@ -222,4 +224,4 @@
222224
return new CustomForm(this, options);
223225
};
224226

225-
})(jQuery);
227+
})(jQuery);

0 commit comments

Comments
 (0)