How fire click event once on Project Server 2019?

Iron Contributor

I have this js:

var attachSaveEvent = setInterval(function() { if ($("#Ribbon\.ContextualTabs\.ProjectDrilldown\.Tasks\.Update\.PublishProject-Large").length == 1) { $('#Ribbon\.ContextualTabs\.ProjectDrilldown\.Tasks\.Update\.PublishProject-Large').click(function() { var res_pwa_big = PWAGreetingToDb(_spPageContextInfo.userId, GetParameterValues('ProjUid')); if (res_pwa_big == 'error') { console.log('Error:on:PublishProject-Large:click'); } }); } if ($("#Ribbon\.ContextualTabs\.ProjectDrilldown\.Tasks\.Update\.PublishProject-Small").length == 1) { $('#Ribbon\.ContextualTabs\.ProjectDrilldown\.Tasks\.Update\.PublishProject-Small').click(function() { { var res_pwa_small = PWAGreetingToDb(_spPageContextInfo.userId, GetParameterValues('ProjUid')); if (res_pwa_small == 'error') { console.log('Error:on:PublishProject-Small:click'); } }); } },500); }

This fire several times (2,3,5,...). How can it fire once on Button click? If I use clearInterval(attachSaveEvent), I can't fire second, third ... click.

BR, Vasily

0 Replies