Commit e641c1d4 authored by David HAN SZE CHUEN's avatar David HAN SZE CHUEN

Set the input tag type and name with jQuery's attr() method to avoid any string escaping issue

Factorise some code too
parent 81328b18
......@@ -339,12 +339,13 @@
buildDropdownOptions: function() {
this.$select.children().each($.proxy(function(index, element) {
var $element = $(element);
// Support optgroups and options without a group simultaneously.
var tag = $(element).prop('tagName')
var tag = $element.prop('tagName')
.toLowerCase();
if ($(element).prop('value') === this.options.selectAllValue) {
if ($element.prop('value') === this.options.selectAllValue) {
return;
}
......@@ -353,7 +354,7 @@
}
else if (tag === 'option') {
if ($(element).data('role') === 'divider') {
if ($element.data('role') === 'divider') {
this.createDivider();
}
else {
......@@ -549,15 +550,14 @@
var $label = $('label', $li);
$label.addClass(inputType);
var $checkbox = $('<input/>').attr('type', inputType);
if (this.options.checkboxName) {
$label.append('<input type="' + inputType + '" name="' + this.options.checkboxName + '" />');
}
else {
$label.append('<input type="' + inputType + '" />');
$checkbox.attr('name', this.options.checkboxName);
}
$label.append($checkbox);
var selected = $element.prop('selected') || false;
var $checkbox = $('input', $li);
$checkbox.val(value);
if (value === this.options.selectAllValue) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment