Fixed FieldAdder js Clone bug

Uniphix

Active member
I am using the FieldAdder part of the XenForo.js script. Now when I add a SpinBox into the FieldAdder to clone it will create multiple +/- when it should only create it once, the first +/- works fine but the others which shouldn't be there are appearing.

Now I can hotfix it on my end with no problem, but for me to update I would have to add it everytime.

Find where it says $clone = $source.last().clone(); and either before or after the disable button, clearing values etc. add

Code:
$clone.find('.spinBoxButton').remove();
 
This is really one specific case of a fairly generic problem. I think changing this properly would involve changing the way the template entry is defined.

That said, I have tweaked this case. Note that you can listen for the FieldAdderClone event and manipulate the clone before it's inserted.
 
Oh, well that is a good thing I didn't even think to see that. Thanks Mike for fixing it. Now that I see that it will help with some other areas, such as I may need to do some specific indexing rather than having something like parameters[$index][name] parameters[$index][type] etc. if I needed to now knowing about that event I can be able to do more :).

But again thanks for fixing this!
 
Top Bottom