Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

BUGFIX: fixed sortable fields (again) not working on initial page loa…

…d or when accessing a page directly. BUGFIX: fixed typo of livequery to live.
  • Loading branch information...
commit 4e6a9ec41230b166d29d18202fd9fce04a617fa8 1 parent e7ba589
Will Rossiter authored

Showing 1 changed file with 44 additions and 64 deletions. Show diff stats Hide diff stats

  1. +44 64 javascript/UserForm.js
108 javascript/UserForm.js
@@ -5,71 +5,57 @@
5 5 */
6 6 (function($) {
7 7 $(document).ready(function() {
8   -
9   - /**
10   - * Update the Field sortable
11   - */
12   - set_sortable();
13   -
14 8 /**
15 9 * Update the sortable properties of the form as a function
16 10 * since the application will need to refresh the UI dynamically
17 11 */
18   - function set_sortable() {
19   - /**
20   - * Sort Fields in the Field List
21   - */
22   -
  12 + function update_sortable() {
  13 + $("#Fields_fields").sortable({
  14 + handle: '.fieldHandler',
  15 + cursor: 'pointer',
  16 + items: 'li.EditableFormField',
  17 + placeholder: 'removed-form-field',
  18 + opacity: 0.6,
  19 + revert: 'true',
  20 + change : function (event, ui) {
  21 + $("#Fields_fields").sortable('refreshPositions');
  22 + },
  23 + update : function (event, ui) {
  24 + var sort = 1;
23 25
24   - $("#Fields_fields").sortable({
25   - handle: '.fieldHandler',
26   - cursor: 'pointer',
27   - items: 'li.EditableFormField',
28   - placeholder: 'removed-form-field',
29   - opacity: 0.6,
30   - revert: 'true',
31   - change : function (event, ui) {
32   - $("#Fields_fields").sortable('refreshPositions');
33   - },
34   - update : function (event, ui) {
35   - update_fieldsSortingOrder();
36   - }
  26 + $("li.EditableFormField").each(function() {
  27 + $(this).find(".sortHidden").val(sort++);
  28 + });
  29 + }
37 30 });
38 31
39   - /**
40   - * Sort Options in a Field List - Such as options in a
41   - * dropdown field.
42   - *
43   - */
44   - $(".editableOptions").sortable({
45   - handle: '.handle',
46   - cursor:'pointer',
47   - items: 'li',
48   - placeholder: 'removed-form-field',
49   - opacity: 0.6,
50   - revert: true,
51   - change : function (event, ui) {
52   - $(this).sortable('refreshPositions');
53   - },
54   - update : function (event, ui) {
55   - update_editableOptionsSortingOrder();
56   - }
  32 + $(".editableOptions").sortable({
  33 + handle: '.handle',
  34 + cursor:'pointer',
  35 + items: 'li',
  36 + placeholder: 'removed-form-field',
  37 + opacity: 0.6,
  38 + revert: true,
  39 + change : function (event, ui) {
  40 + $(this).sortable('refreshPositions');
  41 + },
  42 + update : function (event, ui) {
  43 + var sort = 1;
  44 + $(".editableOptions li").each(function() {
  45 + $(this).find(".sortOptionHidden").val(sort++);
  46 + });
  47 + }
57 48 });
58 49 }
59   -
60   - function update_fieldsSortingOrder(){
61   - var sort = 1;
62   - $("li.EditableFormField").each(function() {
63   - $(this).find(".sortHidden").val(sort++);
64   - });
65   - }
66   -
67   - function update_editableOptionsSortingOrder(){
68   - var sort = 1;
69   - $(".editableOptions li").each(function() {
70   - $(this).find(".sortOptionHidden").val(sort++);
71   - });
72   - }
  50 +
  51 + update_sortable();
  52 +
  53 + /**
  54 + * Workaround for not refreshing the sort
  55 + */
  56 + $(".fieldHandler").live('hover', function() {
  57 + update_sortable();
  58 + })
73 59
74 60 /*--------------------- SUBMISSIONS ------------------------ */
75 61
@@ -149,8 +135,7 @@
149 135 }
150 136 });
151 137
152   - //update_sortable();
153   - update_fieldsSortingOrder();
  138 + $("#Fields_fields").sortable('refresh');
154 139
155 140 return false;
156 141 });
@@ -251,9 +236,6 @@
251 236 }
252 237 });
253 238
254   - //update_sortable();
255   - update_editableOptionsSortingOrder();
256   -
257 239 return false;
258 240 });
259 241
@@ -274,7 +256,7 @@
274 256 /**
275 257 * Custom Rules Interface
276 258 */
277   - $(".customRules .conditionOption").livequery('change',function(){
  259 + $(".customRules .conditionOption").live('change',function(){
278 260 var valueInput = $(this).siblings(".ruleValue");
279 261 if($(this).val() != "" && $(this).val() != "IsBlank" && $(this).val() != "IsNotBlank") {
280 262 valueInput.removeClass("hidden");
@@ -326,8 +308,6 @@
326 308 // append to the list
327 309 currentRules.append(newRule);
328 310
329   - //update_sortable();
330   -
331 311 return false;
332 312 });
333 313 });

0 comments on commit 4e6a9ec

Please sign in to comment.
Something went wrong with that request. Please try again.