BUGFIX: fixed sortable fields (again) not working on initial page load or when accessing a page directly. BUGFIX: fixed typo of livequery to live.

This commit is contained in:
Will Rossiter 2010-10-13 21:07:53 +00:00
parent e7ba58970f
commit 4e6a9ec412

View File

@ -5,22 +5,11 @@
*/ */
(function($) { (function($) {
$(document).ready(function() { $(document).ready(function() {
/**
* Update the Field sortable
*/
set_sortable();
/** /**
* Update the sortable properties of the form as a function * Update the sortable properties of the form as a function
* since the application will need to refresh the UI dynamically * since the application will need to refresh the UI dynamically
*/ */
function set_sortable() { function update_sortable() {
/**
* Sort Fields in the Field List
*/
$("#Fields_fields").sortable({ $("#Fields_fields").sortable({
handle: '.fieldHandler', handle: '.fieldHandler',
cursor: 'pointer', cursor: 'pointer',
@ -32,15 +21,14 @@
$("#Fields_fields").sortable('refreshPositions'); $("#Fields_fields").sortable('refreshPositions');
}, },
update : function (event, ui) { update : function (event, ui) {
update_fieldsSortingOrder(); var sort = 1;
$("li.EditableFormField").each(function() {
$(this).find(".sortHidden").val(sort++);
});
} }
}); });
/**
* Sort Options in a Field List - Such as options in a
* dropdown field.
*
*/
$(".editableOptions").sortable({ $(".editableOptions").sortable({
handle: '.handle', handle: '.handle',
cursor:'pointer', cursor:'pointer',
@ -52,24 +40,22 @@
$(this).sortable('refreshPositions'); $(this).sortable('refreshPositions');
}, },
update : function (event, ui) { update : function (event, ui) {
update_editableOptionsSortingOrder();
}
});
}
function update_fieldsSortingOrder(){
var sort = 1;
$("li.EditableFormField").each(function() {
$(this).find(".sortHidden").val(sort++);
});
}
function update_editableOptionsSortingOrder(){
var sort = 1; var sort = 1;
$(".editableOptions li").each(function() { $(".editableOptions li").each(function() {
$(this).find(".sortOptionHidden").val(sort++); $(this).find(".sortOptionHidden").val(sort++);
}); });
} }
});
}
update_sortable();
/**
* Workaround for not refreshing the sort
*/
$(".fieldHandler").live('hover', function() {
update_sortable();
})
/*--------------------- SUBMISSIONS ------------------------ */ /*--------------------- SUBMISSIONS ------------------------ */
@ -149,8 +135,7 @@
} }
}); });
//update_sortable(); $("#Fields_fields").sortable('refresh');
update_fieldsSortingOrder();
return false; return false;
}); });
@ -251,9 +236,6 @@
} }
}); });
//update_sortable();
update_editableOptionsSortingOrder();
return false; return false;
}); });
@ -274,7 +256,7 @@
/** /**
* Custom Rules Interface * Custom Rules Interface
*/ */
$(".customRules .conditionOption").livequery('change',function(){ $(".customRules .conditionOption").live('change',function(){
var valueInput = $(this).siblings(".ruleValue"); var valueInput = $(this).siblings(".ruleValue");
if($(this).val() != "" && $(this).val() != "IsBlank" && $(this).val() != "IsNotBlank") { if($(this).val() != "" && $(this).val() != "IsBlank" && $(this).val() != "IsNotBlank") {
valueInput.removeClass("hidden"); valueInput.removeClass("hidden");
@ -326,8 +308,6 @@
// append to the list // append to the list
currentRules.append(newRule); currentRules.append(newRule);
//update_sortable();
return false; return false;
}); });
}); });