Reputation: 6569
Is there any way using which when a user opens a url http://www.website.com/page/#delete-page
and if that page has a twitter bootstrap modal with same id delete-page
it should open instantly.
So in theory the user opens the url, The page loads and after its successfully loaded the modal opens (i..e if it exists if not then nothing happens)
Upvotes: 4
Views: 6127
Reputation: 905
Try something like this, it should work.
$(document).ready(function() {
if(window.location.href.indexOf('#myModal') != -1) {
$('#myModal').modal('show');
}
});
Or
$(document).ready(function() {
if(window.location.href==='mysite.com/#myModal'){
$('#myModal').modal('show');
}
}
Upvotes: 1
Reputation: 19356
What do you need?
Once you have the hash, simple get the element with the id selector of the hash and then:
$(hash).modal('show')
Upvotes: 13