Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [Jquery] Lightbox i delegate
Forum PHP.pl > Forum > Po stronie przeglądarki
Monter08
Witam!
Mam mały problem z poprawnym ustawieniem funkcji delegate, aby w każdej części strony używała lightboxa fancybox.
Ustawiam go mniej więcej w taki sposób
  1. $("a[rel=fotobox]").fancybox({
  2. 'transitionIn' : 'none',
  3. 'transitionOut' : 'none',
  4. 'titlePosition' : 'over',
  5. 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
  6. return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
  7. }
  8. });

i nie mam pomysłu jak ustawić go przez funkcje delegate.
Necsord
  1. $('body').delegate("a[rel=fotobox]", 'click', function () {
  2. $.fancybox({
  3. 'transitionIn':'none',
  4. 'transitionOut':'none',
  5. 'titlePosition':'over',
  6. 'titleFormat':function (title, currentArray, currentIndex, currentOpts) {
  7. return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length +
  8. (title.length ? '   ' + title : '') + '</span>';
  9. }
  10. });
  11. return false;
  12. });

http://api.jquery.com/delegate/

jQuery 1.7+
  1. $('body').on('click', "a[rel=fotobox]", function () {
  2. $.fancybox({
  3. 'transitionIn':'none',
  4. 'transitionOut':'none',
  5. 'titlePosition':'over',
  6. 'titleFormat':function (title, currentArray, currentIndex, currentOpts) {
  7. return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length +
  8. (title.length ? '   ' + title : '') + '</span>';
  9. }
  10. });
  11. return false;
  12. });

http://api.jquery.com/on/
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.