The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group
Attach a pop-up form to a button
Hi,
I have installed the modal bootstrap pop-up and would like to have a form appear when a visitor clicks on a "contact-us" button. At the moment the button takes them to a new page, but I'd prefer a pop-up form!
What would be the best way to achieve this?
Thanks
February 14, 2018 at 11:18 am
You can use a jquery event listener for this. You'll have to plug this into your theme just before </body> or add it into custom external js file you may have. You can hide the form by appending <form style="display:none;">
//Set event listener on contact us button
$('#contact-us').on('click',function() {
$(this).show();
});
February 14, 2018 at 11:29 am
Sorry, I forgot to show the bootstrap way of doing it
You can place the modal in the same place</body>. Disregard my last post. Use the below button which would call your data-target which is the id
Contact Button
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
Discussion closed.