Best way of showing more results with javascript/css
Posted
by
Ricardo Neves
on Stack Overflow
See other posts from Stack Overflow
or by Ricardo Neves
Published on 2014-06-03T21:17:24Z
Indexed on
2014/06/03
21:24 UTC
Read the original article
Hit count: 193
I'm developing a website and i'm having troubles showing the search results to the user the way I want. Basically, after the user search, the page makes a couple of ajax requests and as soon as a response arrive it appends the info to a specific element on my page. Each results is shown as a line... The problem is that in most case there are going to be more than 1000 results and this would make the page have a large scroll. My idea was to show only the first 15 results and when the user clicks "show more" the element would expand and show the next 15 results and so on... This would be easier to do if the website wasn't responsive, but because it is I can't find the proper way of implementing what I want without lowering the website perfomance.
I have "2 ideas":
The first is by using something like #element .div:nth-child(-n+15)
on my css and figure a way of changing the "15" to how much results I want to show... I don't know if this can be done. Is it possible to call css rules with parameters? Maybe with less css?
The second option is probably a bad option if i don't want to lower the website performance. Using javascript I would check if there is a specific css class(like .show-15 .show30 .show45) and add that class to my element and if it don't exist, create it somehow..
Any help would be appreciated.
© Stack Overflow or respective owner