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

Prepend items instead of appending them (option) #77

Open
miguelavaqrod opened this issue Nov 12, 2017 · 1 comment
Open

Prepend items instead of appending them (option) #77

miguelavaqrod opened this issue Nov 12, 2017 · 1 comment

Comments

@miguelavaqrod
Copy link

miguelavaqrod commented Nov 12, 2017

Hi,

First of all, I want to thank you for this library that solved quickly a requirement I had. Nice!

I needed to modify the library, so when adding new items, they prepend to the already created ones.
It was so easy that I put here my changes (sorry, I am not able right now to make a PR... if anyone can it would be fine).

In jquery.repeater.js, find function appendItem, and in the return value, modify:

$list.append($item);

with

if(!fig.prependItems){
$list.append($item);
}else{
$list.prepend($item);
}

Now, you just need to add "prependItem: true" to the initialization object, and it will prepend items. If not added, all remain the same.

Regards

@miguelavaqrod miguelavaqrod changed the title Prepend items instead of append them (option) Prepend items instead of appending them (option) Nov 12, 2017
@miguelavaqrod
Copy link
Author

miguelavaqrod commented Nov 12, 2017

Just a note I've discovered about this change...

Every time you prepend an item, indexes are recreated and the library put '0' index to the new item, '1' index to the next and so...

Wow!

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

1 participant