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

Feature Request: return validated fields in DOM order #88

Open
davidecantini opened this issue Jan 23, 2016 · 4 comments
Open

Feature Request: return validated fields in DOM order #88

davidecantini opened this issue Jan 23, 2016 · 4 comments

Comments

@davidecantini
Copy link

Hi @jonjamz ,

I've just noticed that if input fields are re-rendered in a different order with respect to the original one, then the validated data are returned still according to the previous DOM order.
Would it be possible (at least to have an option) to have the fields returned according to the DOM order at the time the action function is invoked? That is the order one would get by simply using jQuery $('.reactive-element').

Thank you for your attention

@jonjamz
Copy link
Owner

jonjamz commented Jan 23, 2016

This is a cool idea. What do you think is the use case for this functionality? I think I would have to flag elements in the DOM by field in order to accomplish this.

@davidecantini
Copy link
Author

This is a real case scenario I'm facing: fields representing tree nodes. If the nodes get rearranged, the DOM gets properly updated according to the new tree structure, but the library fails to provide the proper order.
At this point either the library or the app (using the library) has to do some extra steps.
Do you think it would be possible to add an option in the action function (or wherever it's more appropriate) to enable DOM sorting and letting it disabled if not needed?

@jonjamz
Copy link
Owner

jonjamz commented Jan 25, 2016

Perhaps I didn't fully understand the issue at first glance.

https://github.com/meteortemplates/forms/blob/master/src/module.js#L556

Right now we collect the DOM elements using findAll. This happens at the time the action is run. Are you saying that the solution to this issue is to use a jQuery selector instead? Seems like a simple fix actually.

@davidecantini
Copy link
Author

That should work. According to jQuery specs, elements are returned in document order since version 1.3.2 ( http://blog.jquery.com/2009/02/20/jquery-1-3-2-released/ )

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