Moorcam Posted July 22 Share Posted July 22 Hi guys, Not sure where this one should be posted but will post here. Please move to appropriate if needed. I am trying to open a new modal by clicking a link inside another one. It doesn't seem to want to play ball and the open modal just closes. Can anyone give me a punch bag or maybe just point me in the right direction? The button: <button type="button" id="viewcharterBtn" data-bs-toggle="modal" data-bs-target="#viewcharterModal<?php echo $row['id']; ?>" data-bs-dismiss="modal" class="btn btn-primary">View</button> The modal I want to open: <div tabindex="-1" class="modal" id="viewcharterModal<?php echo $row['id']; ?>" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"><h4><i class="fa fa-map-marker fa-fw"></i><?php echo $row['charter_name']; ?></h4></div> <div class="modal-body"> <h3><?php echo $row['charter_name']; ?></h3> <p>Leaving at <?php echo $row['dep_date']; ?></p> <p>Customer's name is <?php echo $row['customer_name']; ?> and their contact number is <?php echo $row['customer_number']; ?>.</p> <p>The vehicle for this trip is <?php echo $row['fleet_number']; ?></p> </div> <div class="modal-footer"> <button type="button" class="btn btn-danger" data-bs-dismiss="modal"><i class="fa fa-ban"></i> <?php echo lang('CLOSE'); ?></button> </div> </div> </div> </div> Any help would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/322466-opening-one-bootstrap-modal-from-another-not-working/ Share on other sites More sharing options...
requinix Posted July 22 Share Posted July 22 Been a while since I've done Bootstrap... Have you tried configuring it to open the other modal without closing the current one? Quote Link to comment https://forums.phpfreaks.com/topic/322466-opening-one-bootstrap-modal-from-another-not-working/#findComment-1630567 Share on other sites More sharing options...
Moorcam Posted July 22 Author Share Posted July 22 5 minutes ago, requinix said: Been a while since I've done Bootstrap... Have you tried configuring it to open the other modal without closing the current one? Yeah gave that a crack. Still same. Closes original one and doesn't open the new one. Quote Link to comment https://forums.phpfreaks.com/topic/322466-opening-one-bootstrap-modal-from-another-not-working/#findComment-1630569 Share on other sites More sharing options...
requinix Posted July 22 Share Posted July 22 Have you already compared what you have with their example of how to do two modals? Which worked for me... Quote Link to comment https://forums.phpfreaks.com/topic/322466-opening-one-bootstrap-modal-from-another-not-working/#findComment-1630570 Share on other sites More sharing options...
Moorcam Posted July 22 Author Share Posted July 22 8 minutes ago, requinix said: Have you already compared what you have with their example of how to do two modals? Which worked for me... Sure have. Same result. Closes first one but doesn't open the second one. Quote Link to comment https://forums.phpfreaks.com/topic/322466-opening-one-bootstrap-modal-from-another-not-working/#findComment-1630572 Share on other sites More sharing options...
requinix Posted July 22 Share Posted July 22 Does their example work for you? Because if their example works then there's something different... Quote Link to comment https://forums.phpfreaks.com/topic/322466-opening-one-bootstrap-modal-from-another-not-working/#findComment-1630574 Share on other sites More sharing options...
Moorcam Posted July 22 Author Share Posted July 22 7 minutes ago, requinix said: Does their example work for you? Because if their example works then there's something different... Doing exactly what they are doing in the example. Yet, their example works. How stupid is that? Quote Link to comment https://forums.phpfreaks.com/topic/322466-opening-one-bootstrap-modal-from-another-not-working/#findComment-1630577 Share on other sites More sharing options...
Solution requinix Posted July 22 Solution Share Posted July 22 Shot in the dark, but you don't happen to be reusing that second modal's ID for anything else on the page, are you? Can you take the same (partial) markup, stick it into something like JSFiddle, and get it to work? Quote Link to comment https://forums.phpfreaks.com/topic/322466-opening-one-bootstrap-modal-from-another-not-working/#findComment-1630578 Share on other sites More sharing options...
Moorcam Posted July 22 Author Share Posted July 22 1 minute ago, requinix said: Shot in the dark, but you don't happen to be reusing that second modal's ID for anything else on the page, are you? Can you take the same (partial) markup, stick it into something like JSFiddle, and get it to work? That could be the issue. I have a table setup on index.php and when I click View it opens that modal no issues. If I open the View All modal and click on View, it's where the thing uses a toilet. I begin to ask myself why I decided to save space by using modals instead of separate files for each section. Quote Link to comment https://forums.phpfreaks.com/topic/322466-opening-one-bootstrap-modal-from-another-not-working/#findComment-1630579 Share on other sites More sharing options...
Moorcam Posted July 22 Author Share Posted July 22 21 minutes ago, requinix said: Shot in the dark, but you don't happen to be reusing that second modal's ID for anything else on the page, are you? Can you take the same (partial) markup, stick it into something like JSFiddle, and get it to work? Changing the ID of the modal I want to open from the other modal works. So with that plan we shall go. Thanks mate. Love your work. Quote Link to comment https://forums.phpfreaks.com/topic/322466-opening-one-bootstrap-modal-from-another-not-working/#findComment-1630581 Share on other sites More sharing options...
Moorcam Posted July 22 Author Share Posted July 22 (edited) Ok, that created a new issue. It opens the modal but only for one of the entries. <button class="btn btn-primary" data-bs-target="#viewCharter<?php echo $row['id']; ?>" data-bs-toggle="modal">View</button> <div tabindex="-1" class="modal fade" id="viewCharter<?php echo $row['id']; ?>" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"><h4><i class="fa fa-map-marker fa-fw"></i><?php echo $row['charter_name']; ?></h4></div> <div class="modal-body"> <h3><?php echo $row['charter_name']; ?></h3> <p>Leaving at <?php echo $row['dep_date']; ?></p> <p>Customer's name is <?php echo $row['customer_name']; ?> and their contact number is <?php echo $row['customer_number']; ?>.</p> <p>The vehicle for this trip is <?php echo $row['fleet_number']; ?></p> </div> <div class="modal-footer"> <button type="button" class="btn btn-danger" data-bs-dismiss="modal"><i class="fa fa-ban"></i> <?php echo lang('CLOSE'); ?></button> </div> </div> </div> </div> No idea why but yeah. Edited July 22 by Moorcam Quote Link to comment https://forums.phpfreaks.com/topic/322466-opening-one-bootstrap-modal-from-another-not-working/#findComment-1630583 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.