Was the new router built with support for nested routes that can be combined?


#1

I’ve been hacking on a pure client side pagination / filtering / sorting mixin for some time and recently I got it working for RC1.

http://jsfiddle.net/BBt2h/1/

The fiddle above is what I have currently and it does work … if you only use 1 part of the mixin at a time.

For example, if I got to page 2 but then decide to filter the content down my window.location drops the page # and throws up the filter.

Or if I start filtering, but then decide to hit page #2 the filter is dropped from window.location and the page is added.

The reason my use case requires this is for a simple “copy / paste” situation where my customers want to share a url and in doing so they really benefit from the full context (ie- what page/search/sort was used to achieve the desired view into the controllers model)

So a legit url with all the data might look like this

/records/#/page/2/sort/username/search/dave

My question here is really about the ember v2 router api -was it designed for this scenario? If not today could it be in the future? What would need to change to support this?

Also for the stackoverflow like response -is there something I’m doing above in the fiddle that is causing this not to work when it is technically possible?


#2

Just a note regarding REST URLs. The correct format for URLs like that would be: records/search?page=2&sort=username&q=dave.


#3

So you can achieve this “combined” / “nested” params w/ the api today? is this documented in the guides? if not can you show a trivial example?


#4

@toranb why are you doing the paging on the client? I’m currently doing it on the server and just adding to the array as those pages come in… How much data are you dealing with for this? It seems like a waste to receive hundreds of rows if the user only rarely changes their sorting…

Thoughts?


#5

This should become easier when ember router supports query-strings. There’s an open issue against it and an implementation that works in RC1.


#6

@i_am_brennan this was both a conceptual problem and a “here is one implementation” -so about the pagination client side only … not a great long term solution clearly. I’d actually really like to see what your server side pagination looks like. Are you using ember-data or is this home grown? could you throw together a jsfiddle for others like me who are looking for solid solutions to the common line of business problems (ie- pagination/sorting/filtering)


#7

Hey @toranb, didn’t see this until now. I’ll see if I can create an example of my pagination code tomorrow. I am using ember-data, but hacking my way through/around that I don’t fully understand.