1

I am using the jqPagination from Ben Everard. It's a nice plugin and saved me coding pagination logic.

I have a search and a button ,when a user enters a value and clicks the button I do Ajax search and the following to update the paginator:

$('#search-by-quote-id-paginator').jqPagination('option', 'current_page', 1);

$('#search-by-quote-id-paginator').jqPagination('option', 'max_page', totalpages);

(This required because on the screen the paginator may be showing the "page x of xxx". Since the user has launched a new search by entering in the search box and pressed the button. )

However each of those lines triggers a page: event and my page: function gets executed. How can I turn off triggering of the "page:" event selectively , I want it to happen only on the following line:

$('#search-by-quote-id-paginator').jqPagination('option', 'current_page', 1);

so I want to turn it off for the following line

$('#search-by-quote-id-paginator').jqPagination('option', 'max_page', totalpages);

Thanks !

Harinder

Ben Everard
  • 13,652
  • 14
  • 67
  • 96
user2412398
  • 471
  • 4
  • 10
  • Hi Harinder... this is a good question, never thought people would want to turn ofd the `paged` callback, I'll consider adding something to sort this out. In the meantime you could reference a boolean variable within the `paged()` callback of which you could drop out of the function early, that'd be the best bet in the short term. – Ben Everard May 23 '13 at 14:48
  • Added a github issue for this https://github.com/beneverard/jqPagination/issues/19 – Ben Everard May 23 '13 at 14:53

2 Answers2

3

This issue has now been fixed in version 1.3 of the plugin.

You can now set multiple options with one call to the option function, this includes the option to not trigger the paged() callback:

$(".pagination").jqPagination("option", {
    max_page : 1,
    current_page : 50,
    trigger : false
});
Ben Everard
  • 13,652
  • 14
  • 67
  • 96
  • Hi Ben, --- Getting an error "jqPagination: cannot get / set option current_page" when trying to to a 'get': $('#mypaginator-id').jqPagination('option', 'current_page', undefined); <-- old syntax $('#mypaginator-id').jqPagination('option', {'current_page': undefined}); <--- new syntax As per jquery.jqpagination.js code that relies on a undefined value in order to a 'get' operation: base.setPage = function (page, prevent_paged) { // return current_page value if getting instead of setting if (page === undefined) { return base.options.current_page; } – user2412398 Jul 31 '13 at 23:23
  • Hi there, have you got a live example of this... or better yet can you replicate in JSBin so I can play with it. Thanks, Ben – Ben Everard Aug 01 '13 at 09:06
0

Thanks for the update.

I have turned off the paged event for the 'max_page' by changing the following line in the function base.setMaxPage = function (max_page) in the jquery.jqpagination.js :

// update the input element

base.updateInput();

was changed to ...

// update the input element

base.updateInput(true);

Thanks ! Harinder

user2412398
  • 471
  • 4
  • 10