I have a method to close bootstrap cards. These cards are loaded in the webpage based on an object array this.unratedjobs
. Upon closing individual cards I remove each card's objects(Elements) form the object array this.unratedjobs
. While removing these cards, I play a lil' animation using JQuery hide function.
Now, my problem is I can't update the global variable inside the callback function, even if I find a way to access it.
As per my findings, I can copy the global variable into the local scope and manipulate but I can't make it affect the global ones.
onDiscardJobCard(jobId?){
if(!jobId){
jobId = this.alertMessageModal.instance.result;
this.addToRateAnotherTime(jobId);
}
//This is assigning a global variable to a local one
var rr = this.unratedJobs;
$('#rating-section-' + jobId).hide('drop', {direction: "left"}, 'slow', function() {
$('#rating-section-' + jobId).remove();
rr = _.filter(rr, r=> r.jobId != jobId);
});
this.alertMessageModal.dismiss();
if(this.unratedJobs && this.unratedJobs.length == 0){
this.onDiscardModal.emit();
}
}
I have tried many ways but none worked successfully.