Obsah fóra
PravidláRegistrovaťPrihlásenie




Odpovedať na tému [ Príspevok: 1 ] 
AutorSpráva
Offline

Užívateľ
Užívateľ
Obrázok užívateľa

Registrovaný: 02.04.11
Prihlásený: 14.08.14
Príspevky: 74
Témy: 31
Príspevok NapísalOffline : 08.06.2013 14:28

Hello,

pouzivam infinite scroll v jednom tabe, funguje to ako ma, co vsak chcem dosiahnut je nasledovne:

Infinite scroll sa aktivuje az ked sa aktivuje 4.tab (co funguje v poriadku).
Nasledne ale ked prepnem na akykolvek iny tab a scrollnem tam, vidim v console, ze v 4 tabe sa zatial nacitava dalsi obsah. Tomuto chcem zamedzit.
Druha chyba je, ze ked potom opatovne prepnem na 4.tab, funckia sa spusti opat a loaduje uz natiahnuty obsah :-/
Vedel by mi niekto pomoct ako upravit funkcie?

infinite scroll:
Kód:
(function($) {
   $.fn.scrollPagination = function(options) {
      
      var settings = {
         nop     : 10, // The number of posts per scroll to be loaded
         offset  : 0, // Initial offset, begins at 0 in this case
         error   : 'No More Posts!', // When the user reaches the end this is the message that is
                                     // displayed. You can change this if you want.
         loading : 'Loading...',
         delay   : 500, // When you scroll down the posts will load after a delayed amount of time.
                        // This is mainly for usability concerns. You can alter this as you see fit
         scroll  : true // The main bit, if set to false posts will not load as the user scrolls.
                        // but will still load if the user clicks.
      }
      
      // Extend the options so they work with the plugin
      if(options) {
         $.extend(settings, options);
      }
      
      // For each so that we keep chainability.
      return this.each(function() {      
         
         // Some variables
         $this = $(this);
         $settings = settings;
         var offset = $settings.offset;
         var busy = false; // Checks if the scroll action is happening
                           // so we don't run it multiple times
         
         // Custom messages based on settings
         if($settings.scroll == true) $initmessage = $settings.loading;
         else $initmessage = 'Click for more';
         
         // Append custom messages and extra UI
         $this.append('<div class="content"></div><div class="loading-bar">'+$initmessage+'</div>');
         
         function getData() {
            
            // Post data to ajax.php
            $.post($settings.url, {
                  
               action        : 'scrollpagination',
                number        : $settings.nop,
                offset        : offset,
                variables     : $settings.variables,
                  
            }, function(data) {
                  
               // Change loading bar content (it may have been altered)
               $this.find('.loading-bar').html($initmessage);
                  
               // If there is no data returned, there are no more posts to be shown. Show error
               if(data == 0) {
                  $this.find('.loading-bar').addClass('nopost-bar');   
                  $this.find('.nopost-bar').html($settings.error);   
               }
               else {
                  
                  // Offset increases
                   offset = offset+$settings.nop;
                     
                  // Append the data to the content div
                     $this.find('.content').append(data);
                  
                  // No longer busy!   
                  busy = false;
                  
                  // RE-call uniform for checkboxes
                  $('.accomodation_list input[type="checkbox"]').uniform();
                  
               }   
                  
            });
               
         }   
         
         getData(); // Run function initially
         
         // If scrolling is enabled
         if($settings.scroll == true) {
            
            // .. and the user is scrolling
            $(window).scroll(function() {
               
               // Check the user is at the bottom of the element
               if($(window).scrollTop() + $(window).height() > $this.height() + $settings.height_offset && !busy) {
                  
                  // Now we are working, so busy is true
                  busy = true;
                  
                  // Tell the user we're loading posts
                  $this.find('.loading-bar').html($settings.loading);
                  
                  // Run the function to fetch the data inside a delay
                  // This is useful if you have content in a footer you
                  // want the user to see.
                  setTimeout(function() {
                     
                     getData();
                     
                  }, $settings.delay);
                     
               }   
            });
            
         }
         
         // Also content can be loaded by clicking the loading bar/
         $this.find('.loading-bar').click(function() {
         
            if(busy == false) {
               busy = true;
               getData();
            }
         
         });
         
      });
   }

})(jQuery);


definicia tabov a volanie scrollera:
Kód:
$(document).ready(function() {
                           
                           // accomodation - TABS
                           var $tabs = $('#content #content_box #accomodation_detail #tabs').tabs();
                              
                           var active_tab = $tabs.tabs({
                              activate: function(event ,ui){

                                     if(ui.newTab.index() == 4) // if active tab REVIEWS
                                     {
                                        var $scroller = $('#comments').scrollPagination({
                                       
                                       url      : './ajax/accomodation_review_show.php',
                                       
                                       variables: {
                                           aid      : '<? echo htmlspecialchars($accomodation["aid"]); ?>',
                                           lang   : '<? echo htmlspecialchars($lang); ?>',
                                        },
                  
                                       nop     : 5, // The number of posts per scroll to be loaded
                                       offset  : 0, // Initial offset, begins at 0 in this case
                                       height_offset : 1000,
                                       error   : 'No More Posts!', // When the user reaches the end this is the message that is
                                                                   // displayed. You can change this if you want.
                                       loading : 'Loading...',
                                       delay   : 500, // When you scroll down the posts will load after a delayed amount of time.
                                                      // This is mainly for usability concerns. You can alter this as you see fit
                                       scroll  : true // The main bit, if set to false posts will not load as the user scrolls.
                                                      // but will still load if the user clicks.
                                       
                                    });
                                     }
                                     else
                                     {
                                        // stop scroller
                                     }
                                 }
                           });
                           
                        });


Odpovedať na tému [ Príspevok: 1 ] 


Podobné témy

 Témy  Odpovede  Zobrazenia  Posledný príspevok 
V tomto fóre nie sú ďalšie neprečítané témy. infinite scroll

v PHP, ASP

6

490

01.03.2016 22:31

stenley Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. jquery datepicker v ajax taboch

v JavaScript, VBScript, Ajax

4

306

05.06.2013 13:40

general667 Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. Problem s encodovanim v Taboch(Jquery UI

v JavaScript, VBScript, Ajax

6

472

28.05.2011 13:44

coldak Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. jQuery .scroll() problém

v JavaScript, VBScript, Ajax

2

547

05.12.2010 20:03

Ando Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. Google Chrome problem "scroll in scroll"

v Ostatné programy

5

468

09.08.2012 19:57

Ormi Zobrazenie posledných príspevkov

Táto téma je zamknutá, nemôžete posielať nové príspevky alebo odpovedať na staršie. Scroll up

v JavaScript, VBScript, Ajax

13

517

05.03.2014 18:05

Ďuri Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. back - scroll

v Ostatné

7

549

06.12.2008 14:33

Flety Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. scroll lock

v Externé zariadenia

1

1228

04.08.2007 22:37

Jaro Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. hp, nefunguje scroll

v Notebooky a netbooky

3

2342

04.04.2010 22:38

davider137 Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. Nastavenie div scroll

v HTML, XHTML, XML, CSS

4

492

03.07.2010 11:40

camo Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. scroll v ubuntu :(

v Operačné systémy Unix a Linux

7

875

07.12.2008 16:18

dadmtb Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. scroll na hp 620

v Externé zariadenia

3

563

22.08.2011 14:16

michalesku Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. auto scroll po refresh

v HTML, XHTML, XML, CSS

18

1290

17.09.2010 11:47

coldak Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. Scroll Bar in TRichEdit

v Delphi, Visual Basic

0

744

21.01.2009 17:48

Fico Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. Problém so scroll barom na touchpade

v Ovládače

4

1262

27.09.2016 16:01

Petersson Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. Bioshock Infinite

[ Choď na stránku:Choď na stránku: 1, 2 ]

v Počítačové hry

44

1292

16.04.2013 23:50

Slayer Zobrazenie posledných príspevkov


Nemôžete zakladať nové témy v tomto fóre
Nemôžete odpovedať na témy v tomto fóre
Nemôžete upravovať svoje príspevky v tomto fóre
Nemôžete mazať svoje príspevky v tomto fóre

Skočiť na:  

Powered by phpBB Jarvis © 2005 - 2024 PCforum, webhosting by WebSupport, secured by GeoTrust, edited by JanoF
Ako väčšina webových stránok aj my používame cookies. Zotrvaním na webovej stránke súhlasíte, že ich môžeme používať.
Všeobecné podmienky, spracovanie osobných údajov a pravidlá fóra