-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collectionbinder sort static content #210
base: master
Are you sure you want to change the base?
Collectionbinder sort static content #210
Conversation
…dicated container and for a container with some other static content.
…ent into account and don't move it to bottom each time
Not that I don't support this, but I wonder if it would make things simpler to just have the CollectionBinder require an empty parent element? The "static content" case is then handled by adding another container for the bound models themselves:
As it is, it's sort of a behavioral quirk that we happen to be using Just my 2 cents. I'm otherwise happy to see this go in-- just think we're fixing a problem we could easily avoid. |
My thoughts exactly. In the OP's use case, pointing the Collectionbinder On Fri, Feb 20, 2015 at 10:25 AM, Kevin Partington <[email protected]
Roger Roger Roelofs |
Adding another container works if you have div-based markup. I realize it's quite a rare case, and an alternative solution would be to use js for manually handling groups of rows instead of using multiple tbodies. Sent from my T-Mobile 4G LTE Device -------- Original message -------- From: Kevin Partington Date:02/20/2015 7:25 AM (GMT-08:00) To: "theironcook/Backbone.ModelBinder" Cc: amakhrov Subject: Re: [Backbone.ModelBinder] Collectionbinder sort static content
(#210) As it is, it's sort of a behavioral quirk that we happen to be using .append fairly exclusively and so the static content "works". In particular, it does not work if we wanted the static content to be at the bottom, etc. Admittedly, that would probably be a breaking change and should go in with a new release version; but I think it would make things easier to reason about here. Just my 2 cents. I'm otherwise happy to see this go in-- just think we're fixing a problem we could easily avoid. — |
@amakhrov I'll admit I hadn't thought of that possibility. You are right that tables do not support nesting tbody or other related elements to make this work properly. I guess in that case, I would rather see support for "extra" elements be made explicit and not automatic. (For example, if the ViewManagerFactory takes in as an option Again, that's totally a breaking change and I don't insist on this pull request being closed/altered to acommodate my design philosophy. I accept that this pull request is solving a real issue that was exposed by the auto-sort feature. I'm just thinking long-term: in my view, for 2.x, we need to consider solidifying the design of CollectionBinder and making its behavior simpler in the default case (and requiring consumers to opt in to more complicated behavior). |
When we call collectionBinder.bind we pass a container to it.
Sometimes this container includes some content that is not a part of the collection itself - e.g. table header. I call such content "static content", as it's not supposed to be dynamically changed with collectionBinder.
So the issue is that the static content moves to the bottom of the container each time sortRootEls is called. The expected behavior I think is not to touch the static content during sorting at all.
The added unit tests demonstrate the issue.
The suggested solution is to check the position of the first collection element before the sorting starts, and then adjust the algorithm to take that into account.