Comments (9)
Hi,
I was thinking a long time about this, when I designed the API of Paging and concluded, that this issue should be handled by the user.
As you can read off your description, your usecase is quite specific. I could imagine to introduce a new options directive which blocks the onSelect call within the library.
Could you formulate, how you would like the API to be to solve your two issues? I mean on what stages of the API interaction you would lock/unlock the callback? I don't want to introduce a single directive like "no init callback" or something as I want the library to be as generic as possible
Robert
from jquery-paging.
Hi, thanks for getting back to me so promptly, I appreciate it.
I guess that in terms of keeping things as generic as possible, the initialisation and adjustment of the count wouldn't carry with them any side effects at all. The initialisation would simply set up the pagination, so that it would be ready to interact with. A method could be called on the object returned, which would fetch the data for whatever page (1st by default). Setting a new count would change the number of pages shown in the control. To me it seems like a separate thing to fire the event in both of these cases, as neither of the methods suggest that any new data should be requested.
Perhaps it would be better if it weren't necessary to call setPage
after setNumber
- incidentally, I was caught out by this when first using the plugin. That way, setPage
could still trigger the onSelect
behaviour, whereas setNumber
by itself wouldn't.
Cheers,
Tom
from jquery-paging.
In case it is useful, I resolved this in the end by setting an additional option on the pager before calling setPage()
:
pager.setNumber(count).setOptions({ preventRefresh: true }).setPage();
In my onRefresh
callback function I then did:
if (pager.opts && pager.opts.preventRefresh === true) {
pager.setOptions({
preventRefresh: false
});
return;
}
This returns early from the function before doing the AJAX call which was causing the infinite loop.
I hope that someone else finds this useful, as I found the default behaviour quite unintuitive. Anyway, thanks for making the plugin!
Cheers,
Tom
from jquery-paging.
Hi Tom,
thanks for your work. I'll leave the ticket open and implement a standard hook for this case when I have some time for it. Sorry for my sparse communication on that.
Robert
from jquery-paging.
Hi,
I have run into this infinite loop issue when I simply want to do to redirect with the onSelect method. Reading above I see that this gets call on init() and probably why I am stuck in an infinite loop. For example my onSelect is the following function:
function (page) { window.location.replace(url+page) }
where url is path to a page. As you can see since the default page has this code on it, then it will infinitely loop. Any help will be appreciated.
James
from jquery-paging.
I figure out a solution, which was to check the complete window.location.href variable in order to determine whether the new url with the page parameter from onSelect function was the same as the current page href. If so, then it must have been an init of the page through some other method outside of clicking the pagination plugin.
from jquery-paging.
But it's not work when you use post ajax requests and window.location.href is same.
Anyway, I think we need additional option to fire or not to fire onSelect at init.
from jquery-paging.
Could you please provide a jsfiddle or pastebin?
from jquery-paging.
I don't understand last question for me? Provide which part of what? Anyway, I have resolved problem myself.
from jquery-paging.
Related Issues (20)
- Avoiding a Circular Dependency HOT 1
- Unnecessary fill element HOT 2
- How to find the paging element from onSelect? HOT 2
- Not working when less than 5 pages HOT 3
- Example with Socket.io HOT 5
- Current page changes before data is updated HOT 1
- FEATURE: Option for enabling circular navigation needed HOT 6
- License HOT 1
- Logarithmic Pagination
- Slicing without hashchange HOT 4
- Scroll to top of list on pagination click HOT 1
- How to identify the current page HOT 2
- P and q in format option HOT 12
- Active state of first/last buttons is confusing HOT 5
- Comment in the JS files point to incorrect project HOT 3
- I can not open the examples and documentation site HOT 1
- qq and pp showing as "undefined" HOT 5
- BUG: when displaying fill in group with qq or pp HOT 4
- Examples with qq/pp on demo pages doesn't work HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-paging.