CC-4188: Playlist Builder -> Smart Playlist : sometimes elements do not index properly when add a new criteria row
-fixed
This commit is contained in:
parent
b2d3ee0aa4
commit
90ec046854
|
@ -25,18 +25,8 @@ function setSmartPlaylistEvents() {
|
|||
form.find('a[id^="modifier_add"]').live('click', function(){
|
||||
var id = $(this).attr('id'),
|
||||
row_index = id.charAt(id.length-1),
|
||||
mod_index,
|
||||
criteria_value = $(this).siblings('select[name^="sp_criteria_field"]').val();
|
||||
|
||||
//get index for the new modifier row
|
||||
if ($(this).parent().find('select[name^="sp_criteria_modifier_'+row_index+'_"]').length == 0) {
|
||||
mod_index = 0;
|
||||
} else {
|
||||
var last_mod = $(this).parent().find('select[name^="sp_criteria_modifier_'+row_index+'_"]:last');
|
||||
var last_mod_id = last_mod.attr('id');
|
||||
mod_index = parseInt(last_mod_id.substr(last_mod_id.length-1))+1;
|
||||
}
|
||||
|
||||
//make new modifier row
|
||||
var newRow = $(this).parent().clone(),
|
||||
newRowCrit = newRow.find('select[name^="sp_criteria_field"]'),
|
||||
|
@ -53,27 +43,21 @@ function setSmartPlaylistEvents() {
|
|||
//hide the critieria field select box
|
||||
newRowCrit.addClass('sp-invisible');
|
||||
|
||||
//append modifier index to the new modifier row
|
||||
newRowCrit.attr('name', 'sp_criteria_field_'+row_index+'_'+mod_index);
|
||||
newRowCrit.attr('id', 'sp_criteria_field_'+row_index+'_'+mod_index);
|
||||
//keep criteria value the same
|
||||
newRowCrit.val(criteria_value);
|
||||
newRowMod.attr('name', 'sp_criteria_modifier_'+row_index+'_'+mod_index);
|
||||
newRowMod.attr('id', 'sp_criteria_modifier_'+row_index+'_'+mod_index);
|
||||
|
||||
//reset all other values
|
||||
newRowMod.val('0');
|
||||
newRowVal.attr('name', 'sp_criteria_value_'+row_index+'_'+mod_index);
|
||||
newRowVal.attr('id', 'sp_criteria_value_'+row_index+'_'+mod_index);
|
||||
newRowVal.val('');
|
||||
newRowExtra.attr('name', 'sp_criteria_extra_'+row_index+'_'+mod_index);
|
||||
newRowExtra.attr('id', 'sp_criteria_extra_'+row_index+'_'+mod_index);
|
||||
newRowExtra.val('');
|
||||
disableAndHideExtraField(newRowVal);
|
||||
sizeTextBoxes(newRowVal, 'sp_extra_input_text', 'sp_input_text');
|
||||
newRowRemove.attr('id', 'criteria_remove_'+row_index+'_'+mod_index);
|
||||
|
||||
//remove the 'criteria add' button from new modifier row
|
||||
newRow.find('.criteria_add').remove();
|
||||
|
||||
$(this).parent().after(newRow);
|
||||
reindexElements();
|
||||
appendAddButton();
|
||||
appendModAddButton();
|
||||
removeButtonCheck();
|
||||
|
|
Loading…
Reference in New Issue