0

I'm trying to make something like that: https://www.easybring.com/#registration

as you can see, "registration" is in a jquery dialog, which can be opened by clicking on regiser button inside the website. Until now i'm good:

<a onClick="showDialog({$product['id']});">More Info </a>

My Head contains:

function showDialog(productID){
    $( "#dialog-modal_"+productID ).dialog({
        width: 770,
        height: 590,
        modal: true,
        open: function(event, ui){
        }
    });
}

And of course i have the div:

<div id="dialog-modal_{$product['id']}" style="display: none;">
<iframe src="index.php?act=showProduct&id={$product['id']}" width="100%" height="100%" frameborder="0" scrolling="no"></iframe> 
</div>

But what I want to do, is to call that jquery specific dialog, by website url: #registration.

How can i do it?

Thanks a lot!

Tushar Gupta - curioustushar
  • 58,085
  • 24
  • 103
  • 107
user1936192
  • 335
  • 2
  • 4
  • 10

3 Answers3

2

This one should work:

$(document).ready(function() {
if( window.location.href.indexOf( '#registration' ) != -1 ) {
    showDialog({$product['id']});
}
});

Hope it helps :)

Avishek
  • 1,896
  • 14
  • 33
0

You can handle your url on document load event:

$(function() {
    if (window.location.toString().indexOf('#registration') > -1) {
        showDialog({$product['id']});
    }
});

Code might not work but I think that idea is clear.

This might help you to work with url string in JS: How to get the anchor from the URL using jQuery?

Community
  • 1
  • 1
Samich
  • 29,157
  • 6
  • 68
  • 77
0

Why don't you call showDialog() inside $(document).ready()

Something like this

 $(document).ready(function(){
    $("#dialog-modal").dialog({modal: true});
});
sk8terboi87 ツ
  • 3,396
  • 3
  • 34
  • 45