Abrir iframe en lugar de publicar

I have a problem with jQuery: when i click in Inicio on a thumb image opens the iframe but when i click on a filter item and on the image thumb opens up the post. This is my website tests: [oscurecido]

Why when i click on a filter and then on the image thumb opens the post instead of iframe?

Thank you and sorry for my bad english!

preguntado el 08 de noviembre de 11 a las 12:11

I't seems that when you filter the portfolio items the binded behavior is lost. There's a line in your JS commented with /* When a portfolio item is clicked */. Is there where you tell the portfolio items to open that "iframe" you say? If so, and I'm just guessing here, try changing this call portfolioItemsEnabled.click( function (e) { a algo como esto: $('#portfolio-items.enabled li').live("click", function(e) { -

@scumah I tried but it doesn't work! and then with this it hangs quicksand and Firebug gives me this error: Uncaught TypeError: Property '$' of object [object DOMWindow] is not a function. Thank you so much anyway! -

@scumah there was a small mistake, I replaced the $ con jQuery and now it works. Thank you very much scumah! -

No problem, i'll post it as a more extended answer if you don't mind :P -

1 Respuestas

When you filter the portfolio items, those are regenerated dynamically, so the previously binded behavior is lost (In your case, a click event).

To solve that jQuery has the .En Vivo() event, which attaches the event handler not only to current DOM elements but also to elements created in the future (i.e. not created when the DOM was loaded but later).

In your .js code you have this call:

portfolioItemsEnabled.click( function (e) {
  if(!jQuery(this).hasClass('active') && jQuery(this).hasClass('visible')) {    
    portfolioItems.removeClass('active');
    jQuery(this).addClass('active');
    portfolioItems.not('.active').find('.overlay').css({ display: 'none' });
    var postId = jQuery(this).attr('id').split('portfolio-')[1];
    tz_getPortfolio(postId);
  }
  e.preventDefault();
});

And in order to make it work anytime, even when new/different portfolio items are loaded, you should change the call like this

jQuery('#portfolio-items.enabled li').live("click", function(e) {
  if(!jQuery(this).hasClass('active') && jQuery(this).hasClass('visible')) {    
    portfolioItems.removeClass('active');
    jQuery(this).addClass('active');
    portfolioItems.not('.active').find('.overlay').css({ display: 'none' });
    var postId = jQuery(this).attr('id').split('portfolio-')[1];
    tz_getPortfolio(postId);
  }
  e.preventDefault();
});

respondido 08 nov., 11:21

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.