I am creating a custom Joomla 2.5 formfield. This is intended to be shown in Administrator panel of Joomla.
This field allows the user to add as many options as they like. Each option is entered by the user in a separate text-box. Each text box is created dynamically (using jQuery) on click of a (+)
button
jQuery(lihtml).insertBefore( jQuery(plusbutton).closest('li') );
where lihtml
is the html code to insert.
And user can also remove any existing option by clicking (-)
button
jQuery(minusbutton).closest('li').remove();
These all function works fine though after removing an option if we add some other option then everything goes great. But the following sequence causes problem:
REMOVE-OPTION -> SAVE
option is removed, but save doesn't work
REMOVE-OPTION -> SAVE -> ADD-OPTION
form is submitted and hence save method is called on click of a button.
I know that there is some conflict, may be with DOM, or jQuery memory leakage, but not sure.
I can see that save
button updates the task
field (hidden) with customfield.apply
but actual submit is called only after clicking (+)
button.
NOTE:
Instead of SAVE, the same case also applies with any toolbar button in Joomla, like SAVE AS NEW, CANCEL etc.