Pagination in JavaScript

Поделиться
HTML-код
  • Опубликовано: 12 июн 2024
  • How to use Vanilla Javascript to paginate a list of items in a table view in a Frontend Application. Pagination is used to limit the amount of items that display on screen at once. This Javascript tutorial we show a specific amount of items and navigate through each page using pagination.
    GitHub: github.com/TylerPottsDev/vani...
    Discord: / discord
    Twitter: / tyler_potts_
    Music: DEAF KEV - Invincible (NCS Release)
    #JavaScript #Pagination #Tutorial

Комментарии • 80

  • @fiction-bo3if
    @fiction-bo3if 2 года назад +2

    works perfectly. Made a few adjustments to my own project but after following your explanation it's finally working as intended. Thank you.

  • @yoselyncallejas7913
    @yoselyncallejas7913 3 года назад +7

    This video is seriously so underrated. Thanks a bunch! It helped me a lot. The only thing I'm missing is the prev. and next buttons, I will try and figure it out.

  • @FrankUnderwoood
    @FrankUnderwoood 2 года назад +5

    Thanks to this tutorial I've finally figured out how to implement a working pagination! 😃Thank you!

  • @mandy2481
    @mandy2481 4 года назад +7

    Thank you so much for this video! This really helped me for my project!

  • @jonathonsong3513
    @jonathonsong3513 3 года назад +3

    You sir are a great teacher thanks for the help made it really easy to understand was searching for other alternatives for the language i was actually using but ended up going off of your methods thanks to you being able to break it down so easy thank you for giving back to the community

  • @oeddsprimers4217
    @oeddsprimers4217 4 года назад +4

    Excellent tutorial vid... everything works by the end (Jan-004-2020)
    - well done, cheers, and thanks Tyler

  • @greob
    @greob 3 года назад +3

    Thanks for sharing this, you make it look simple and straight-forward.

  • @--VICKY-
    @--VICKY- 3 года назад +3

    thank you, I thought it might be tooooo hard to implement. but you way of teaching and clarity explanation made it easier. once again thank you keeeep teaching

  • @miguelship3
    @miguelship3 4 года назад +2

    Awesome dude!! I had to figured it out how to do the same on react and it worked perfectly, thanks for the enlightment!

  • @erickbuitrago7555
    @erickbuitrago7555 3 года назад +2

    Muchas gracias, hombre! No pude entender lo que decías debido a que no sé inglés, pero pude implementarlo en mi proyecto. Agradecido contigo

  • @DEBO5
    @DEBO5 2 года назад +1

    The perfect pagination tutorial

  • @jamespaulchibole266
    @jamespaulchibole266 Год назад +1

    Thank you for the posting. It is very helpful.

    • @TylerPotts
      @TylerPotts  Год назад

      Glad it was helpful!

    • @jamespaulchibole266
      @jamespaulchibole266 Год назад

      @@TylerPotts Thank you, I am now struggling to fetch the data for pagination from a query in database. Any suggestion, pointers or help will be appreciated.

    • @jamespaulchibole266
      @jamespaulchibole266 Год назад

      A got a solution, no warries.

  • @anahitharutyunyan3066
    @anahitharutyunyan3066 Год назад +2

    Thank you for your clear explanation. It helps me do my project.

  • @harishvithal584
    @harishvithal584 2 года назад +1

    Thank you so much sir, this is so helpfull, it helped me alot!

  • @AshutoshNigam68
    @AshutoshNigam68 4 года назад +2

    Thanks for sharing, this is a life saver.

  • @StrrUe
    @StrrUe 4 года назад +11

    thank you! after hours and hours of googling i finally came across this video and it helped me so much

    • @TylerPotts
      @TylerPotts  4 года назад

      Happy to help!

    • @coltencoleman5513
      @coltencoleman5513 3 года назад

      a tip: you can watch movies at Flixzone. I've been using them for watching loads of movies these days.

    • @ayaancallan2716
      @ayaancallan2716 3 года назад

      @Colten Coleman Definitely, I've been watching on Flixzone for since november myself :)

  • @SuperCodepk
    @SuperCodepk Год назад

    Thank you, man!

  • @WzrLvDJ666
    @WzrLvDJ666 2 года назад

    gracias por enseñar este tema de paginacion esta muy bien la logica para sacar este proyecto

  • @AsimYilan
    @AsimYilan 3 года назад +1

    best Tutorial what i watched. thx a lot

    • @TylerPotts
      @TylerPotts  3 года назад +1

      Glad it helped!

    • @AsimYilan
      @AsimYilan 3 года назад

      @@TylerPotts I Love your script but i have a big porblem and hope you can help me.
      Your list_itens looks "Item 1", "Item 2", "Item 3".....
      But when i try your script with JSON i cant use it.
      I get this JSON encoded from PHP on MySQL Database with echo json_encode($data);
      i catch this with ajax get but i cant run this on your script. In console.log i can see the index in JSON data
      What must i do. I need your help

  • @FrankGP.com.
    @FrankGP.com. Год назад

    Thankyou Very much

  • @user-nc4mo5cq5f
    @user-nc4mo5cq5f 3 года назад +1

    БОЖЕ ЧУВАК СПАСИБО!!!!!!! ПРОСТО СПАСИБО ТЕБЕ!!!!!!!!!!!!

  • @carlosz1858
    @carlosz1858 2 года назад +1

    thanks bro, i was able to set up my first pagination, even though i had to watched it more than twices 😂, greetings 👍

  • @jslover3687
    @jslover3687 Год назад

    Thanks, this video is wonderful! What color theme do you use?

  • @sandorferenc3101
    @sandorferenc3101 2 года назад

    Thank you very much! :D

  • @jgonz8394
    @jgonz8394 Год назад

    what did you do that the item boxes show up? did the script exactly and nothing in my html or css that i update can make the item boxes show up.

  • @giorgosstergiou2492
    @giorgosstergiou2492 Год назад

    RESPECT!!!

  • @Aditya-ch6dk
    @Aditya-ch6dk 2 года назад

    Helpful...bro can you tell how we can loop trough JSON data? as in video you have just used an Array...

  • @sunnie8460
    @sunnie8460 2 года назад

    Hi, at the end of the page when there are only a few items left, the pagination bar got pushed up. How to fix this?

  • @ahakanyildiz
    @ahakanyildiz 3 года назад

    I thought you were having seizure at 08:27 mate. I don't understand how you guys understand this accent. Thanks for the well working tutorial.

  • @GrahamRSteele
    @GrahamRSteele 3 года назад

    This is awesome. An absolutely great tutorial. One question though. When you created the PaginationButton function and added the 'current_page' variable, I noticed that it wasn't declared in that function, nor was it passed to the function. I thought that, for sure, this wasn't going to work. But it did in yours and not in mine. What gives?

    • @GrahamRSteele
      @GrahamRSteele 3 года назад

      Nevermind! Got it. Firstly, I had the constants and current_page in a jQuery document.ready tag. I also had the functions above the constants and lets. Duh.

  • @rugambajesus3644
    @rugambajesus3644 2 года назад

    Hi is there any way of showing maybe like 1to 6 button and show other as you click, thanks!!

  • @nolose6542
    @nolose6542 2 года назад

    thanks u !!

  • @paolacintolesi4150
    @paolacintolesi4150 3 года назад

    Thank you very much, it was very useful to me. Please, I need to implement the same pagination but inside some tabs, and I'm losing the current tab when I change the page number.... Please, anyone does know how could I fix it?, or Where could I find information? Thank you so much...

  • @masoudanaraki8881
    @masoudanaraki8881 Год назад

    thank a million time body :)))))))

  • @suvineetsingh8140
    @suvineetsingh8140 2 года назад

    I have an error informing items.slice(start, end) is not a function.

  • @arjunm1205
    @arjunm1205 4 года назад

    Can you share your wallpaper? Love it

  • @lonleybeer
    @lonleybeer 3 года назад +1

    How do you do it with an API?

  • @dmalvi2002
    @dmalvi2002 2 года назад +1

    You literally saved my ass!

  • @mahyarazad
    @mahyarazad 3 года назад

    Thank you so much for your nice and insightful tutorial. I should say I am a newbie in JS, anyhow, I have added two functions for "Next" and "PREV". I guess they are working properly among the other functions.
    adding the buttons inside the SetupPagination():
    let next = document.createElement('button');
    next.id = "next";
    let prev = document.createElement('button');
    prev.id = "prev"
    var s = document.getElementsByTagName('button')[0]
    prev.innerText = 'Previous';
    next.innerText = 'Next';
    wrapper.insertBefore(prev,s);
    Next and Prev Functions:
    function nextp (page,items,rows){
    let page_count = Math.ceil(items.length/rows);
    document.getElementById("next").addEventListener('click', () => {
    let page = document.querySelector(".active");
    if(parseInt(page.id) === page_count ){
    } else {
    current_page = parseInt(page.id) + 1;
    DisplayList(items, list_element, rows, current_page);
    page.classList.remove('active');
    let pop = document.getElementById(current_page);
    pop.classList.add('active');
    }
    });
    }
    function prevp (page,items){
    document.getElementById("prev").addEventListener('click', ()=> {
    let page = document.querySelector(".active");
    if (parseInt(page.id)===1){
    } else {
    current_page = parseInt(page.id) - 1;
    DisplayList(items, list_element, rows, current_page);
    page.classList.remove('active');
    let pop = document.getElementById(current_page);
    pop.classList.add('active');
    }
    });
    }

    • @CrazyFanaticMan
      @CrazyFanaticMan 2 года назад

      It didn't work for me, can you link your github so I can check out the code please and thank you

  • @alvingultiano7513
    @alvingultiano7513 Год назад

    can you do pagination by div not by items ?

  • @mustaphamusah9672
    @mustaphamusah9672 3 года назад

    Wao! so helpful. I am trying to replace the "list_item" content with object-object items in the JS file but my end result was blank, Tyler I need your help😟.
    example:
    const myQuestions = [
    {
    question: "Who invented JavaScript?",
    answers: {
    a: "Douglas Crockford",
    b: "Sheryl Sandberg",
    c: "Brendan Eich"
    },
    correctAnswer: "c"

  • @windrider0429
    @windrider0429 4 года назад

    how do you limit the number of pages you see? for example 1...456...10.

    • @windrider0429
      @windrider0429 4 года назад

      Also how do you create a first and last page? I can't figure it out. by the way I'm just a novice.

    • @rugambajesus3644
      @rugambajesus3644 2 года назад

      Hi, have you managed to implement the page limit

  • @theoligarchist1503
    @theoligarchist1503 3 года назад +2

    CSS destroyed this demo, it gets in the way. i am newbie and this makes me wonder how to avoid CSS, unreadable code.

  • @AndrewB0
    @AndrewB0 4 года назад +2

    Would you think this could be used if the content was already on the page?
    Text, images and all types of fun!
    Text, images and all types of fun!
    Text, images and all types of fun!

    • @AndrewB0
      @AndrewB0 4 года назад +1

      Also this is great! Just having trouble wrapping my mind around how I want to tweak for my needs, but I keep coming back to your video..

    • @TylerPotts
      @TylerPotts  4 года назад

      I hope it helps but I'm not sure, I think you could use it? :)

  • @buran_7
    @buran_7 2 года назад

    Тот случай когда понял язык не зная его

  • @xlMoiSt
    @xlMoiSt 4 года назад +8

    You could probably just skip the HTML/CSS on tutorials like these.

    • @TylerPotts
      @TylerPotts  4 года назад +10

      I agree but I feel like if I skip the HTML/CSS then someone will complain that I didn't do it... :)

    • @michalolos1715
      @michalolos1715 4 года назад +1

      @@TylerPotts better to create time-stamp to jump over the html/css for each likes :) i like your job, thanks :)

  • @travel_ghost22
    @travel_ghost22 4 года назад

    i came here just for the JS logic and it is really sad that although tutorial was good but because you speak sofast I stopped in middle of the video and wrote this comment and one more suggestion is where you are writing a logic please explain it clearly you speak fast and frequently change the things

    • @SohCahToa30
      @SohCahToa30 3 года назад

      Pause, rewind, and adjust playback speed.

  • @kamalsharma2839
    @kamalsharma2839 Год назад

    I don't know why most liked the video but to me video is like just copying pasting the youtuber code and straightway get a working code (pretty much like we already can from forums or searches) as only few things were explained, rest were just straightway writing without explanation. I simply didn't like the video