superRaytin / paginationjs

A jQuery plugin to provide simple yet fully customisable pagination.
http://pagination.js.org
MIT License
912 stars 659 forks source link

How to add extra parameter in ajax url send except pageNumber & pageSize #36

Closed squalvj closed 6 years ago

squalvj commented 7 years ago

hi, i'd like to know how i add extra parameter in example, i want to add parameter like type='test' so in url become : /test.json?pageNumber=2&pageSize=10&type=test

thankyou mate, your plugin is awesome

squalvj commented 7 years ago

the issue has been fix, i simply add 'data' object in ajax

$('#pagination-container').pagination({ dataSource: 'https://localhost/rizraz/api.php', locator: 'name', totalNumber: <?php echo $num_rows?>, pageSize: 8, alias: { pageSize: 'limit', pageNumber: 'current' }, ajax: { data : { monyet: 100 }, beforeSend: function() { dataContainer.html('Loading data from flickr.com ...'); } }, callback: function(data, pagination) { // template method of yourself var html = template(data); dataContainer.html(html); } })

much thanks bro

dmitryrn commented 7 years ago

Yes, you can also add another param to path like that and that will be concatenated (but your variant is better):

container.pagination({
        dataSource: 'http://mytube.loc/api/posts?withCount',
        totalNumber: 25,
        locator: 'posts',
        totalNumberLocator: (response) => {
          return response.count
        },
        pageSize: 5,
        className: 'paginationjs-theme-blue',
        ajax: {
          beforeSend: (pagination, d, c) => {
            $("html, body").animate({ scrollTop: 0 }, 600)
          }
        },
        callback: (response, pagination) => {
          this.currentPage = pagination.pageNumber
          this.posts = response
        }
      })
dkarandana commented 6 years ago

@squalvj this is only working for non dynamic data if you passed like Math.random() it will not change. Any ideas ?

diego06884 commented 6 years ago

@superRaytin hi, has @dkarandana question been solved? Thanks!

superRaytin commented 6 years ago

@dkarandana @diego06884 you can solve it by passing ajax as a function now :) , pls upgrade to 2.1.3

dkarandana commented 6 years ago

@superRaytin super cool !