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

How to implement repeterVal () #45

Closed
jorarmarfin opened this issue Jan 31, 2017 · 8 comments
Closed

How to implement repeterVal () #45

jorarmarfin opened this issue Jan 31, 2017 · 8 comments

Comments

@jorarmarfin
Copy link

No description provided.

@jorarmarfin
Copy link
Author

please

@yociduo
Copy link

yociduo commented Feb 4, 2017

please use $repeater.repeaterVal()

@jorarmarfin
Copy link
Author

jorarmarfin commented Feb 4, 2017 via email

@yociduo
Copy link

yociduo commented Feb 4, 2017

$repeater is your element.
For the title, I guess you have miss spelling with the extension name.

@jorarmarfin
Copy link
Author

jorarmarfin commented Feb 4, 2017 via email

@yociduo
Copy link

yociduo commented Feb 5, 2017

There is an example in the README.md, you can try it.
It will return an object for form

@jorarmarfin
Copy link
Author

In the README.md file only mentions
// setup the repeater
$ ('. Repeater').
// get the values of the inputs as a formatted object
$ ('. Repeater').
But I still do not know how to use repeaterVal ()
An example please

@DubFriend
Copy link
Owner

the repeaterVal method is sort of convenience method to get the values of inputs within the repeater.

The original design of jquery.repeater was to be used in a "web 1.0" style, where the form triggers a full page refresh (as opposed to an ajax call). jquery.repeater sets the name parameter in a way that it generates a nicely structured data when parsed on the server (at least in php). For example an input in jquery.repeater with the name "foo" would be rewritten to something like "repeater-name[0][foo]" so that it is parsed on the server as an element in an array with the field name "foo". In this case you probably wouldn't need to use repeaterVal.

However if you need to access the values of repeater inputs using client side javascript, this naming convention could be annoying. So .repeaterVal returns the data in a structured way that would mirror the way your server-side parsing might structure it.

Your best bet might be to simply try calling repeaterVal on a repeater and see what data it returns. This would probably be more instructive than my poor explanation 😄

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

3 participants