Событие нажатия кнопки удаляет только одну подчиненную форму и после не работает - PullRequest
0 голосов
/ 16 января 2019

Проект выполнен в Adobe LiveCycle Designer на JavaScript.

У меня есть кнопка добавления, которая добавляет один экземпляр подчиненной формы, и кнопка удаления, которая удаляет один экземпляр подчиненной формы.

Когда я нажимаю удалить, он удаляет только одну подчиненную форму. Если я нажимаю на него снова, он ничего не делает ... Что мне делать?

_veg1.removeInstance(_veg1.count-1);


var rd = frmO.caption.value.resolveNode("#text").value;;
if (frmO.rawValue == null){
app.alert("Mai intai trebuie sa completati campul: " + rd + "!");
xfa.host.setFocus(frmO);
xfa.host.openList(frmO);
}
else{

/*
This button will Remove the current instance of the repeating subform or 
table row.

bCalc: Flag - true if the removed instance might be referenced by other 
calculations, otherwise false.  
message: The error message displayed.
*/  
var bCalc = true;
var message = "Ați atins numărul minim de elemente permise.\n\nVor fi 
sterse datele introduse in campurile acestui element!";

// DO NOT MODIFY THE CODE BEYOND THIS POINT - 
10.0.2.20120224.1.869952.867557 - Subform_Instance_Controls_IRM.xfo.p4

var oWrapper = this.parent.parent;  // The outer subform built in to the 
object, enclosing the button group.
var oTargetSubform = oWrapper.parent;   // The subform or table row the 
controls are intended to manipulate.
var oManager = oTargetSubform.instanceManager;  // Get the instance 
manager.
var nMinCount = oManager.occur.min;         // Get the minimum 
number of subform occurrences allowed.
var nSubCount = oManager.count;             // Get the 
current number of instances.

// Proceed if the minimum number of subform occurrences has not been 
reached.
if (nSubCount > nMinCount) {

// Invoke the Instance Manager.
oManager.removeInstance(oTargetSubform.index);

// Fire the form calculations.
if (bCalc == true) {

    // Execute all the form calculations.
    xfa.form.recalculate(1);
}

} else {
    var raspuns = xfa.host.messageBox(message,"Remove Item",2,2);
    if (raspuns == 4){
    _prod.setInstances(0);
    _prod.setInstances(1);
    }
}

// END OF DO NOT MODIFY
}
...