views:

104

answers:

1

I'm using this script as a popup on my website for a login.

But what im having trouble with is that it makes me put the HTML code of the popup in my index or page whichever will display the popup. Is there a way to make it so that i can call the popup code externally like whatever is in the popup?

This is the popup code im using!

http://yensdesign.com/2008/09/how-to-create-a-stunning-and-smooth-popup-using-jquery/

Help would be awesome i just cant figure it out anymore....

A: 

Maybe you could use the load() function inside the function that makes the popup appear?

Seems like loadPopup() is the function that shows the popup.

//loading popup with jQuery magic!
function loadPopup(){
   //loads popup only if it is disabled
   if(popupStatus==0){

      // load popup content from external file
      $("#popupContact").load("popupContent.html");

      $("#backgroundPopup").css({
         "opacity": "0.7"
      });
      $("#backgroundPopup").fadeIn("slow");
      $("#popupContact").fadeIn("slow");
      popupStatus = 1;
   }
}
Stian
So using this will pull the code of the popup from another page? And it will work like it did before just with external page containing code right?
mystycs
Yeah, that's the idea. :)But you should probably be aware that the load() function uses AJAX, so it might affect the way the popup is rendered, because elements could be rendered at different times.. But you could try it out.
Stian
Allright ill try it, ill post back telling! Hope me luck :)
mystycs
Wait just curiously where exactly do i add the code "$("#popupContact").load("someExternalPage.html");"
mystycs
I updated the code example in my original post.
Stian
Tried it. Nothing happens
mystycs
You've created a html file called popupContent and put the html of the popup inside? Just to get the obvious out of the way :P
Stian
Yup lol, and i replaced the code you gave me inside the popup.js file
mystycs
Oh and this is the html i have that brings it up when clicked. <div id="button"><li><a onclick="document.form.submit()">Login</a></li> </div>
mystycs
Yea im completely at loss now.
mystycs
I downloaded all the files from the example and modified it the way I have suggested, and it works for me. You say nothing happens, what does that mean? When you click the button to make the popup appear, nothing happens? In that case there could be a syntax error in your code... I tried copy-pasting the code in my example and replaced the loadPopup function in popup.js, and it still works.
Stian
Hmm want to look at my code? Here http://bit.ly/ckJFfeI put the bit.ly cause i dont want my site coming up in this on google haha.Maybe you can find something i missed?
mystycs
Should the popup appear when you click the Login link at the top?
Stian
Yup! Thats how it worked before if the code was just in there.
mystycs
This is the popup.js file if you didnt take a look. http://bit.ly/cyEosP
mystycs
In your popup.js you use an element with id "popupLogin", but I can't find such an element on your page.. Just put a empty div with that id somewhere inside the body tag. Hopefully it will fix it.
Stian
I have that div in my popupcontent.html file here Or should i still add it?http://bit.ly/ak46tv
mystycs
It worked before if i put that code in the popupcontent in my index.html file in my template and didnt have that new code in the js. Thats why im wierded out its not working haha. And yea i replaced it all with popupLogin
mystycs
Aha, now I realize that you have the popupLogin div inside the popupContent.html. But you should have that div on your main page, and it should just be empty. Because now jQuery can't find that element. Also <div id="backgroundPopup"></div> should be on your main page, not in the popupContent.html.
Stian
Okay will do now =) Lets see this work!! haha
mystycs
It works great!!!! Thank you so much! Your awesome, but one thing haha. When i try to close my window now it doesnt. Any idea?http://bit.ly/93iDZv After the popup opens.
mystycs
Yeah, I had the same problem here. In popup.js replace$("#popupLoginClose").click(function(){ disablePopup();}); with $("#popupLoginClose").live("click", function(){ disablePopup();}); But you need to use jQuery 1.4 to use the "live" function, and you're using 1.2.
Stian
Works perfectly! Dude you are the best out of like 20 days of looking you give me the answer! Haha Thanks so much! =)
mystycs
Hehe, no problem! Just remember to accept my answer :P Good night :)
Stian
It has been accepted =)
mystycs