Modals always pose a challenge for me, especially when I'm trying to work with someone else's code that has a unique take on modals that I really appreciate (if only I can make it function correctly).
The issue arises when the modal is supposed to display item-specific information based on an ID. However, upon clicking to exit and selecting the trigger for different item-specific information with a unique ID, the old information is displayed instead. It seems like the modal needs to be reset or destroyed between triggers. Here's how it should ideally work for this project:
- Populate Inventory Page With Database Information
- On Action Click, Pass Item ID to Modal
- Show Modal With Additional Item-Specific Information
- Allow Users to Close Modal and Select Another Item Action
- Repeat Steps 2-4 for Different Items
Here's my existing code:
inventory.php
The Trigger:
<a data-toggle="modal" data-target="#ajax" data-id="<? echo $row['id'];?>" href="./mod/v_email.php?id=<? echo $row['id'];?>" class="btn red btn-sm dropdown-toggle inv_action">Email <i class="icon-note"></i></a>
Then, the modal initialization at the bottom of the page:
<div class="modal fade" id="ajax" role="basic" aria-hidden="true">
<div class="page-loading page-loading-boxed">
<img src="../../assets/global/img/loading-spinner-grey.gif" alt="" class="loading">
<span>
Loading... </span>
</div>
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
v_email.php
$id=($_GET['id']);
<div class="modal-header">
<button type="button" class="close" id="modal_close" data-dismiss="modal" aria-hidden="true"></button>
<h4 class="modal-title">Let someone know!</h4>
</div>
<!-- Rest of your modal content and form goes here -->
In conclusion, there seems to be an issue with resetting or destroying the modal data between triggers, which is causing the incorrect information to be displayed. If you have any insights or need additional information, please feel free to comment so I can provide more details. Thank you.