Links after .html() problem
Hi there!
I'm trying to modify this tutorial:
http://tutorialzine.com/2010/03/sponsor-wall-flip-jquery-css/ in order to add a button to flip the boxes and another to close them. I'm stuck because after adding the content with .html() the '.close' button doesn't work and I don't really understant why... Would you please give me a clue?
THANK YOU!!!
- $(document).ready( function (){
- $( '.open' ).on( "click" , function (){
- var elem = $( this ).closest(". sponsorFlip ");
-
- if (elem.data( 'flipped' ))
- {
- elem.revertFlip();
- elem.data( 'flipped' , false )
- }
- else
- {
-
- elem.flip({
- direction: 'rl' ,
- speed: 250 ,
- onBefore: function (){
- //PROBLEM 1: THE <p class="close">CLOSE</p> INSIDE .sponsorData DOESN'T WORK AFTER .html() INSERT
- elem.html(elem.siblings( '.sponsorData' ).html());
- }
- });
- elem.data( 'flipped' , true );
- // this code is to revert all the flipped boxes
- $(".sponsorFlip").not(elem).each(function(){
- if($(this).data("flipped")){
- // PROBLEM 2: I HAVE TO MODIFY THE TRIGGER IN ORDER TO EXECUTE THE .close CLICK EVENT
- $(this).trigger("click",[true]);
- }
- });
- }
- });
- $(".close").on("click",function(){
- alert("I'd like to revert the flipped box when I'm here. I know I should remove the if/else from .open click event");
- });
- });