Code Monkey home page Code Monkey logo

handlebars-paginate's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

handlebars-paginate's Issues

Missing dependencies

Hello,

Thank you for your work.
You need to put the dependencies in the bower.json file.
Otherwise, the files may be appended in the wrong order when using build tools.

Regards,

Jimmy

Setup

Just giving this another shot and I'm getting the following

ReferenceError: template is not defined

I have the following

app.js

const paginate = require('handlebars-paginate');

hbs.registerHelper('paginate', paginate);

index.hbs

<nav aria-label="Page navigation">
	  <ul class="pagination">
	    {{#paginate pagination type="first"}}
	    <li class="page-item{{#if disabled}} disabled{{/if}}">
	      <a class="page-link" href="?page={{n}}" aria-label="First">
	        <span aria-hidden="true">&laquo;</span>
	        <span class="sr-only">First</span>
	      </a>
	    </li>
	    {{/paginate}}
	    {{#paginate pagination type="previous"}}
	    <li class="page-item{{#if disabled}} disabled{{/if}}">
	      <a class="page-link" href="?page={{n}}" aria-label="Previous">
	        <span aria-hidden="true">&lsaquo;</span>
	        <span class="sr-only">Previous</span>
	      </a>
	    </li>
	    {{/paginate}}
	    {{#paginate pagination type="middle" limit="10"}}
	    <li class="page-item"><a class="page-link{{#if disabled}} disabled{{/if}}" href="?page={{n}}">{{n}}</a></li>
	    {{/paginate}}
	    {{#paginate pagination type="next"}}
	    <li class="page-item{{#if disabled}} disabled{{/if}}">
	      <a class="page-link" href="?page={{n}}" aria-label="Next">
	        <span aria-hidden="true">&rsaquo;</span>
	        <span class="sr-only">Next</span>
	      </a>
	    </li>
	    {{/paginate}}
	    {{#paginate pagination type="last"}}
	    <li class="page-item{{#if disabled}} disabled{{/if}}">
	      <a class="page-link" href="?page={{n}}" aria-label="Last">
	        <span aria-hidden="true">&raquo;</span>
	        <span class="sr-only">Last</span>
	      </a>
	    </li>
	    {{/paginate}}
	  </ul>
	</nav>

routes.js

router.get('/dashboard', ensureAuthenticated, (req, res) => {
  const html = template({pagination: {
    page: parseInt(req.query.page) || 1,
    pageCount: parseInt(req.query.limit) || 6
  }});

  User.find({}, function(err, users) {
    res.render('dashboard/index.hbs', {
      pageTitle: 'Dashboard',
      users: users,
      pagination: {
        page: page,
        pageCount: pageCount
      }
    });
  });
});

First / Last to only appear when actually needed

Hello, I have included extension in my project and got it working.
I have limited my 11 page layout to 5 and included previous and next as outermost links.
Also I have included first and last as [ ... ] links that appear notifying the user that there are more pages available in that direction.

Initial layout looks like this:
image

This works fine. However once I leave page nr.1 and go to nr.2 - first link activates and essentially I have double link to first page:
image

Once nr.4 is reached this again is valid because page nr.1 disappears from view:
image

As we are getting to the end - and last 4 pages are active similar issue appears on the right side - with nr.11 and last [...] page:
image

So my question is regarding this issue - is it possible to disable first and last links until they are really needed and first and last are actually out of the view? I have tried accessing (current)page in attempt to check if offset is reached, however page variable is not available to first and last - inside the pagination object.

Any solution for this?
Thank you.

Add a license

Without a license no-one can knows if they're actually allowed to reuse this code.
Can you add a LICENSE file to the repo?

Prev and Next Buttons are not working Properly

Prev and Next Buttons are not working Properly

Just working for 1 increment or 1 decrement with current page that passed from pagination.

eg:- pagination: { page:5 }
then
next is working up to 6
prievious is working up to 4

{{#paginate pagination type="previous"}}
<li {{#if disabled}}class="disabled"{{/if}}>Prev
{{/paginate}}

{{#paginate pagination type="next"}}
<li {{#if disabled}}class="disabled"{{/if}}>Next
{{/paginate}}

I get this NaN

Am I missing a step?

Added this to my cotroller and passing: pagination: {page: page, pageCount: count}

First Prev NaN NaN NaN NaN NaN NaN NaN Next Last

Can I do a dynamic page count?

Here is my users page

https://gyazo.com/981af3a4c3c065ba4f31c055c2fd5977

As you can see I only have two users here so ideally only one button in the pagination should show here.

In the production app I have 20 users and I have limited the page to only show 6 records in the using the page prefix in the pagination settings however I am still getting 10 pages in the pagination.

Can this be dynamic so the right about of pages in the pagination given the amount of records created?

License discrepancy

According to the README, handlebars-paginate is licensed under MIT, but the package.json says BSD.

production issue - pagination module

Hi,
i am experiencing some strange behaviour
this module works absolutely perfect in development (localhost) BUT in heroku seems to not read this module

I have in my HELPERS folder this:

const hbs = require('hbs');
const paginate = require('handlebars-paginate');
hbs.registerHelper('paginate', paginate);

I noticed some TS warning about @types but i am not working in typescript so...

Could you help me?

Missing css

Hello, where is the class named pagination-centered

how to use this helper with template

I'm looking for a solution to paginate a handlebars template. I don't see how you apply this page number helper to the template that has the data. Any suggestions or examples?

Thanks,
Donnie

how to handle more req.query?

i am trying to include in
<a {{#if disabled}}class="disabled"{{/if}} href="?page={{n}}"><li>First</li></a>

something like:

<a {{#if disabled}}class="disabled"{{/if}} href="{{#if state}}?state={{state}}&{{/if}} {{#unless state}}?{{/state}}page={{n}}"><li>First</li></a>

could you help me to solve that?
thanks for your time and code!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.