Currently, I'm working on integrating a delete function into my ng-repeating accordion component. The delete button appears as expected, and the function is properly set up. However, when the delete button is clicked, the page reloads abruptly and redirects to localhost:8080/# which is not the intended behavior. There seems to be no indication or reason for this redirection, at least none that I can identify. Could this be one of the underlying issues causing this unexpected redirect? Unfortunately, I'm struggling to pinpoint the source of this problem.
Since the application isn't live yet, refreshing the page results in the loss of all data. This data is passed from the previous view to the current editing view, where it is displayed in a table until a row is selected, leading to the editing page.
Below is the JavaScript code for the delete function:
$scope.delete = function (index, event) {
if(event) {
event.preventDefault();
event.stopPropagation();
}
$scope.selectedTestScript.Actions.splice(index, 1);
}
And here is the ng-repeat accordion implementation:
<uib-accordion close-others="oneAtATime">
<uib-accordion-group ng-repeat="action in selectedTestScript.Actions" is-open="action.isOpen" ng-click="action.isOpen=!action.isOpen">
<uib-accordion-heading>
<div>{{action.Description}}<button type="button" class="btn btn-xs btn-danger pull-right" ng-click="delete($index, event)"></i>Delete</button></div>
</uib-accordion-heading>
<div>
<label for="actionNotes" class="control-label col-xs-2">Action Notes</label>
<div class="col-xs-10">
<textarea id="actionNotes" type="text" rows="4"ng-model="action.Notes" class="form-control" name="name"></textarea>
</div>
</div>
<div>
<label for="actionExpected" class="control-label col-xs-2">Action Expected</label>
<div class="col-xs-10">
<input id="actionExpected" type="text" ng-model="action.ExpectedOutcome" class="form-control" name="name">
</div>
</div>
</uib-accordion-group>
</uib-accordion>
I would greatly appreciate any assistance with resolving this issue. I've attempted simplifying the function by eliminating the if(event) statement and only using the splice method, but unfortunately, this approach didn't yield the desired outcome.
Thank you in advance.