2009-08-18 18 views
0

Ok Ich habe das ursprüngliche Problem behoben, aber ich möchte jetzt den Titelwert zurück zu dem Anker-Tag ID = "Kontakt" aus dem ID = "Kontakt-Info" Popup vor ich entferne das Popup-jQuery-Tooltip funktioniert nicht wie erwartet - ÜBERARBEITET

Die JS

this.contactPreview = function() { 
jQuery("a.contact").click(function(e){ 
     this.t = this.title; 
     this.title = ""; 
     var c = (this.t != "") ? "<br />" + this.t : ""; 
     jQuery("body").append("<p id='contact-info'>"+ this.t + "<a id='close-contact' class='close-contact' style='color:red;'>Close</a></p>"); 
     jQuery("#contact-info") 
      .css("top", (e.pageY - xOffset) + "px") 
      .css("left", (e.pageX + yOffset) + "px") 
      .fadeIn(500); 
    }); 

    jQuery("a.close-contact").live('click', function(){ 
     // Need to re-insert the popup info into the original title tag of contact 
     jQuery('#contact-info').remove();   
    }); 
}; 

// Use jQuery() instead of $()for WordPress compatibility with the included prototype js library which uses $() 
// http://ipaulpro.com/blog/tutorials/2008/08/jquery-and-wordpress-getting-started/ 
// See http://chrismeller.com/using-jquery-in-wordpress 
jQuery(document).ready(function(){ 

    // Call the function here 
    contactPreview(); 

}); 

Die CSS

#contact-info{ 
    position:absolute; 
    border:1px solid #ccc; 
    background:#333; 
    padding:5px; 
    display:none; 
    color:#fff; 

Die HTML-

<a class='contact' title='Some info to display'>Display Info</a> 

Vielen Dank im Voraus für jede Hilfe zu diesem

+1

@Phill Pafford - wenn Ihr ursprüngliches Problem gelöst ist, sollten Sie die Antwort ankreuzen, die es gelöst hat und eine andere Frage stellen. – karim79

Antwort

0

http://docs.jquery.com/Events/live den Trick.

Dies fügt das Click-Ereignis automatisch hinzu, wenn CLOSE <A> erstellt wird. Sie haben das Ereignis hinzugefügt, als das Dokument geladen wurde, aber die CLOSE <A> ist noch nicht geladen.

+0

also füge ich die live() zu beiden klicken() ??? –

+0

Nur der Klick, der mit Code erstellt wird. –

+0

hmm das scheint eines der probleme zu beheben, jetzt kann ich die alarm funktion zu arbeiten, aber es kann nicht die id des ursprünglichen tag zu entfernen es. BTW Ich fügte das live() zum Popup –

Verwandte Themen