Hi Everyone!I am currently creating a feature in a mobile application where users who knows a 6-Digit PIN are able to delete an item from a list.Here is how it is supposed to work:The local variable "IsPop" is a boolean variable used for the PopUp Widget. On the home page (Inventory), there is a trash Icon with a Link (LinkOnClick) action with logic that assigns "IsPop" to true when tapped. There is a PopUp Widget in the page that uses the handler "LinkOnClick" to display the PopUp when the icon is tapped. Once the PopUp Widget appears, the PopUp displays an input which allows a certain user who knows the 6-Digit PIN to delete an item from the list. So far, it generally works. However, it deletes the last item from the list and not the item that I tapped on. Does anyone have a solution to this? Please feel free to drop me a message if my explaination is in any way unclear, thanks!Regards,Shen
Hi Shen,
you have positioned the popup inside the list, which means that when you switch the boolean to true, you will get as many popups opened as there are items on your list, the last one on top, i guess.
so that's the one you are then deleting.
A more common pattern is
Dorine
Hi Dorine,Thank you so much for your help, I appreciate it :)Managed to solve the problem with your solution, thank you again!Regards,Shen
Hi @Shen
As the others have mentioned, you are creating a brand new pop-up for each entry, so when you click on the trash icon, it's opening all of them at once, and the last one to open is that of the last entry. This is why it's always deleting the last entry.
Follow @Dorine Boudry's suggestion, this should fix it, but I also noticed that you have an "onclick" event at the PopUp level:
You should also remove this Event along with its handler as it's unnecessary and it would create some inconsistent behavior, as it would be modifying the local variable's value (once the new approach is implemented).
I hope this helps!
Best regards,
Abed
Hi @Abed Al Banna I understand how to solve the problem now, thank you for helping me out! I appreciate it :)Regards,Shen
I'm not sure I understand your functionality. If there's an icon that the user taps, then the user didn't tap an item right? So how is the app supposed to know which item you want to delete?
Hi,
It is not deleting the Id which you are tapping because on the Confirm button(in the popup) the Id passed is not right. It always get the list.current value as Popup is outside list it has separate scope. Create a local variable on screen and assign this as below. On your confirm button pass this local variable instead of list.current. Hope this solves your issue.