Skip to content
This repository was archived by the owner on Jul 29, 2022. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions jquery.jeditable.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,12 @@
},
select: {
element : function(settings, original) {
var select = $('<select />');
$(this).append(select);
var select = settings.multiselect ? $('<select multiple />') : $('<select />');
$(this).append(select);
return(select);
},
content : function(data, settings, original) {
var selectedVals = [];
/* If it is string assume it is json. */
if (String == data.constructor) {
eval ('var json = ' + data);
Expand All @@ -497,20 +498,29 @@
continue;
}
if ('selected' == key) {
if (typeof json[key] == 'string') {
selectedVals.push(json[key]);
} else if (typeof json[key] == 'object') {
for (var i = 0; i < json[key].length; i++) {
selectedVals.push(json[key][i]);
}
}
continue;
}
}
var option = $('<option />').val(key).append(json[key]);
$('select', this).append(option);
}
/* Loop option again to set selected. IE needed this... */
$('select', this).children().each(function() {
if ($(this).val() == json['selected'] ||
$(this).text() == $.trim(original.revert)) {
/* Loop option again to set selected. IE needed this... */
for (var i = 0; i < selectedVals.length; i++) {
$('select', this).children().each(function () {
if ($(this).val() == selectedVals[i] ||
$(this).text() == $.trim(original.revert)) {
$(this).attr('selected', 'selected');
}
});
}
});
}
/* Submit on change if no submit button defined. */
if (!settings.submit) {
if (!(settings.submit || settings.multiselect)) {
var form = this;
$('select', this).change(function() {
form.submit();
Expand Down Expand Up @@ -538,6 +548,7 @@
loadtype : 'GET',
loadtext : 'Loading...',
placeholder: 'Click to edit',
multiselect: false,
loaddata : {},
submitdata : {},
ajaxoptions: {}
Expand Down