Matthieu Matthieu - 3 months ago 7
jQuery Question

How to open modal ?

I have a link in the top menu to add a new event.
When I am on the events list page, this link open a modal with the new event form.
Howether if I am on an other page, I would like this link (in the top menu) to redirect on this events list page with the modal new event form open.

Is it possible ?

Thanks for your help

Answer

Use a hash

link is like:

<a href="/costompagewithmodal#open">link to modal page</a>

in the /costompagewithmodal you show the div if the hash open exist

$(function(){
if(window.location.hash == '#open') {
 $('#myModal').modal('show');
}
})
Comments