Open Bootstrap modal based on a HASH in URL

How can i open the delete bootstrap modal after page load if the URL has a HASH with an id parameter?

Example:

http://example.com/properties#delete-86

Upvotes: 0

Views: 1160

Answers (1)

soywod
soywod

Reputation: 4510

You could do at the begining of your script :

// You can retrieve the id in 'matches' variable if needed
if (matches = window.location.href.match(/#delete-([0-9])+/))
{
    $('#my-modal').modal('show');
}

Upvotes: 2

Related Questions