From 7491e5c9e93474494f9d58ec770cf719ac6bd492 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Mon, 31 May 2010 09:43:52 +0000 Subject: [PATCH] BUGFIX: refresh sortable lists after adding elements --- javascript/UserForm.js | 47 ++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/javascript/UserForm.js b/javascript/UserForm.js index 9945473..b970f1f 100644 --- a/javascript/UserForm.js +++ b/javascript/UserForm.js @@ -64,6 +64,9 @@ statusMessage(ss.i18n._t('UserForms.ERRORCREATINGFIELD', 'Error Creating Field')); } }); + + $("#Fields_fields").sortable("refresh"); + return false; }); @@ -86,7 +89,6 @@ * currently have it open */ $(".EditableFormField .moreOptions").live('click',function() { - var parentID = $(this).parents(".EditableFormField"); if(parentID) { var extraOptions = parentID.children(".extraOptions"); @@ -125,7 +127,9 @@ } } }); + $(this).parents(".EditableFormField").remove(); + return false; }); @@ -204,25 +208,23 @@ * Sort Options in a Field List - Such as options in a * dropdown field. */ - $(".editableOptions").live(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++); - }); - } - }); + $(".editableOptions").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++); + }); + } }); /** @@ -250,8 +252,7 @@ /** * Adding a custom rule to a given form */ - $(".customRules .addCondition").live('click', function() { - + $(".customRules .addCondition").click(function() { // Give the user some feedback statusMessage(ss.i18n._t('UserForms.ADDINGNEWRULE', 'Adding New Rule')); @@ -281,6 +282,8 @@ // append to the list currentRules.append(newRule); + $(".editableOptions").sortable("refresh"); + return false; }); });