this is the solution:
take care that "#idofyousecondarymodal" is the id of the secondary or tertiary or infinite modal. but NEVER write the ID of the first modal.
example i have 2 modal:
.
.
.
.
.
.
.
.
then the script will be:
jus add this code and work fine.