I've been working on this subject matter for like 4 hours and I really cannot figure out why is this happening ..
Here's what is happening.. I have a function to remove an element . then updates remaining element in sequence.
The first time a user remove it works fine, but the next time, does not.
Below are the code on how do I remove the element.
Check the selectedCard
and selectedCardContainer
variable.
function _removeSelectedCard( selectedCard ) {
selectedCard = $(selectedCard).closest(".btn-remove-video");
var selectedCardContainer = _getElementData(selectedCard, "parent");
$(selectedCardContainer).remove();
}
Findings is that selectedCardContainer
returns a value that it's not supposed to be return. e.g., selectedCard
data-attr value = "id-1" but jQuery.data() return "id-2" .
Why is that happening? where did he get that value?
Here's the Fiddle