Neil_Bradley
asked on
Clone numbering
Fiddle ref here
The Fiddle ref shows the dynamic adding of tabs with auto numbering on the cloned panel titles and the panel input id's. Works great.
The numbering however goes out of whack in this scenario.
- Add new panels to the total of 4.
- Now remove number 2 panel.
Although the panel totals show correctly the number sequence is out of whack.
We need to update the cloned panels number sequence after a panel is removed.
Cheers,
N
The Fiddle ref shows the dynamic adding of tabs with auto numbering on the cloned panel titles and the panel input id's. Works great.
The numbering however goes out of whack in this scenario.
- Add new panels to the total of 4.
- Now remove number 2 panel.
Although the panel totals show correctly the number sequence is out of whack.
We need to update the cloned panels number sequence after a panel is removed.
Cheers,
N
ASKER
The end sequence needs to be 1,2,3,4,5... (a numerically sound sequence without skipping any numbers).
This will allow the user to change their mind about item number 3 and remove it completely. After doing this they will be left with 1,2,3,4
Or after removing number 3 then then decide to add 2 more then the sequence will be 1,2,3,4,5,6
Hope this makes sense..
N
This will allow the user to change their mind about item number 3 and remove it completely. After doing this they will be left with 1,2,3,4
Or after removing number 3 then then decide to add 2 more then the sequence will be 1,2,3,4,5,6
Hope this makes sense..
N
check this
https://jsfiddle.net/vsqozkLt/
if this is not what you want, we need to add a function for renumbering...
https://jsfiddle.net/vsqozkLt/
if this is not what you want, we need to add a function for renumbering...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Absolutely beautiful. many thanks HainKurt..
ASKER
10000 bonus points for this one if I could..
I changed template elements as "xxx_xxx_1"
it changes template ids, and headers after deleting...
+ it changes input element ids as well after deleting...
no need to renumbering after adding since addition always will be next number...
it may have bugs, but code should be very clear... you should be able to fix if there is any issues...
it changes template ids, and headers after deleting...
+ it changes input element ids as well after deleting...
no need to renumbering after adding since addition always will be next number...
it may have bugs, but code should be very clear... you should be able to fix if there is any issues...
Open in new window
so after adding one id will be 2, then 3 then 4
after deleting #2 for example, when you add a new one the id will be 4 again! why?
because current count is 3, so 3+1 is 4...
now what do you need here?
should we check all gaps and re-use them or give new id as 5, then 6... we dont care deleted ones...