Retrieving both save buttons via jquery

I am trying to create a JS that would interact with save buttons.
But I ran into a tech problem retrieving the buttons via jquery.

We all know that there’s two buttons SAVE on every module.
On suitecrm 7.10.10 (and certainly earlier) the two buttons have the same ID (aka : SAVE)
To my humble opinion an HTML document containing two tags sharing the same id is invalid (and jquery agrees with me : https://api.jquery.com/id-selector/)

Jquery will return only the first matching element of our selector :

How can we then match the second one ? (i can’t rely on chrome’s $$ as users could use another browser !)

What’s your opinion here guys ? Is there any really good reasons SuiteCRM Dev choosed to identify the two buttons with same ID ?

The truth is that much of this code comes from years ago, maybe no one knows the reason why. I agree with you that on principle there should be unique ids.

Maybe you just try to tweak the screen construction (tpl files) to give them separate ids, and then fix whatever needs to be fixed so the screen still works as expected. If this turns out to be a simple process and works well, we can put the fix into the main code. If it turns out to be a nightmare, then it’s better to find some different way to workaround this issue…

Hi,

We use $(’#EditView’).find(’.button.primary’).
That works also for older versions where the header and footer buttons ids were different.

1 Like