Skip to content
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

If/Ifnot virtual elements don't work #158

Open
ricardobrandao opened this issue Mar 29, 2016 · 5 comments
Open

If/Ifnot virtual elements don't work #158

ricardobrandao opened this issue Mar 29, 2016 · 5 comments

Comments

@ricardobrandao
Copy link
Contributor

If we use the if/ifnot binding inside a virtual element the binding does not work. All works fine if we use container elements (e.g. < div >).

A sample can be seen here.

@ricardobrandao
Copy link
Contributor Author

@rniemeyer I'm facing a problem because of this issue (and I believe that fixing this issue might help solving other problems like the one in #163).

The problem is that since I cannot use if/ifnot virtual elements, the hidden rows are still showing in the DOM and therefore they are processed when sorting the rows.

A fiddle representing this problem can be found here. In this scenario, when we try to move row 1 to row 4 we actually end up moving row 2 to row 6 because we are counting the hidden rows which ends up messing with the table.

@rniemeyer
Copy link
Owner

@ricardobrandao - there needs to be a single element for each sortable thing inside your container. Have you tried maybe something like this: https://jsfiddle.net/rniemeyer/664134y4/

@ricardobrandao
Copy link
Contributor Author

Hi @rniemeyer, thanks for the reply.

I am unable to fully understand what you mean with "single element for each sortable thing". Firstly, because in my container I only have a tr element (this was my first approach but didn't worked as expected, see my original comment). Moreover, I can have, for instance, multiple div elements inside a table cell.

I was trying not to do something like what you are suggesting because I want to apply different actions (e.g. bindings) and styling according to the row type (i.e. view only or editing mode) and it's easier to have two different tr elements (e.g. using templates).

@rniemeyer
Copy link
Owner

@ricardobrandao - I meant that your template should only have one top-level element defined or the index tracking while sorting gets messed up.

@ricardobrandao
Copy link
Contributor Author

Yes, the problem is exactly that.

However I think this would work for my case if we could use the virtual DOM which would actually remove the extra rows. However, in order for that to work we need to enable the virtual DOM for the sortable plugin and probably it would require some refactoring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants