BUGFIX: got drag and drop ordering of field OPTIONS rewritten in jQuery

This commit is contained in:
Will Rossiter 2009-04-18 03:08:34 +00:00
parent c0b2f760cd
commit e73015e6e5
2 changed files with 45 additions and 17 deletions

View File

@ -147,23 +147,50 @@
/** /**
* Sort Fields in the Field List * Sort Fields in the Field List
*/ */
$("#Fields_fields").sortable({ $("#Fields_fields").livequery(function() {
handle : '.fieldHandler', $(this).sortable({
cursor: 'pointer', handle : '.fieldHandler',
items: 'li.EditableFormField', cursor: 'pointer',
placeholder: 'removed-form-field', items: 'li.EditableFormField',
opacity: 0.6, placeholder: 'removed-form-field',
revert: true, opacity: 0.6,
change : function (event, ui) { revert: true,
$("#Fields_fields").sortable('refreshPositions'); change : function (event, ui) {
}, $("#Fields_fields").sortable('refreshPositions');
update : function (event, ui) { },
// get all the fields update : function (event, ui) {
var sort = 1; // get all the fields
$("li.EditableFormField").each(function() { var sort = 1;
$(this).find(".sortHidden").val(sort++); $("li.EditableFormField").each(function() {
}); $(this).find(".sortHidden").val(sort++);
} });
}
});
});
/**
* Sort Options in a Field List - Such as options in a
* dropdown field.
*/
$(".editableOptions").livequery(function() {
$(this).sortable({
handle : '.handle',
cursor: 'pointer',
items: 'li',
placeholder: 'removed-form-field',
opacity: 0.6,
revert: true,
change : function (event, ui) {
$(this).sortable('refreshPositions');
},
update : function (event, ui) {
// get all the fields
var sort = 1;
$(".editableOptions li").each(function() {
$(this).find(".sortOptionHidden").val(sort++);
});
}
});
}); });
}); });
}) })

View File

@ -2,6 +2,7 @@
<img class="handle" src="sapphire/images/drag.gif" alt="<% _t('DRAG', 'Drag to rearrange order of options') %>" /> <img class="handle" src="sapphire/images/drag.gif" alt="<% _t('DRAG', 'Drag to rearrange order of options') %>" />
$DefaultSelect $DefaultSelect
<input type="text" name="$Name.Attr[Title]" value="$Title" /> <input type="text" name="$Name.Attr[Title]" value="$Title" />
<input type="hidden" class="sortOptionHidden" name="$Name[Sort]" value="$Sort" />
<% if isReadonly %> <% if isReadonly %>
<img src="cms/images/locked.gif" alt="<% _t('LOCKED', 'These fields cannot be modified') %>" /> <img src="cms/images/locked.gif" alt="<% _t('LOCKED', 'These fields cannot be modified') %>" />