jquery - basic modal

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

jquery - basic modal

Post by nite4000 »

hey this is first time in this forum I think maybe 2nd but my issue is easy to some.

I have a basic modal popup

here is the code

Code: Select all

<script> 
  $(function() {
//$('#preview').click(function(){
    $( "#dialog-modal" ).dialog({
      height: 500,width: 500,
      modal: true
	  
      
    });
	 });
  //}); 
 
  </script>


as you see I have this commented out $('#preview').click(function(){

and what I need is to make the popup appear when a link is clicked not when the page is loaded

here is my link
<a href="#" id="preview">Preview</a>

whats going on is instead of hiding the content of the popup its showing it at the bottom of the page but when that line is commented out it hides it but popup shows when page is loaded again.

I am not sure what to do since I don't use a lot of jquery.

any help would be great
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: jquery - basic modal

Post by requinix »

nite4000 wrote:hey this is first time in this forum I think maybe 2nd but my issue is easy to some.
I think it's your 174th.
nite4000 wrote:here is my link
<a href="#" id="preview">Preview</a>
I don't know the extension you're using well enough but I'd try without the href=#.

And what do you mean "instead of hiding the content of the popup"?
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

Re: jquery - basic modal

Post by nite4000 »

for your information I do not post in the javascript thread so no its not my 174th and I don't like your attitude either. maybe you should see what I mean before making a rude comment
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: jquery - basic modal

Post by requinix »

I was just joking on how it was your 174th post. Calm down.
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

Re: jquery - basic modal

Post by nite4000 »

I am using it on php and if I leave the # off the href= then it logs me out soon as I click the link mainly since I am telling it to go to the root of the dir
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: jquery - basic modal

Post by requinix »

I mean remove the href entirely.

But actually if that fixes it you'll have another problem: the link won't style like a link anymore (because having a href is what makes it an a:link). Since you're using jQuery a better method would be to use event.preventDefault:

Code: Select all

<script> 
  $(function() {
    $('#preview').click(function(e){
      $( "#dialog-modal" ).dialog({
        height: 500,width: 500,
        modal: true
      });
      e.preventDefault();
    });
  });
</script>
If that doesn't fix it after all, is this live somewhere we can see it?
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

Re: jquery - basic modal

Post by nite4000 »

I tried your code and that didn't help I also removed the href="#" and when the page loads you can see the content of the popup at the bottom

how can I pm your the details of where the live page is at? I prefer not to display the location publicly

I have left your code on there
Post Reply