How fire click event once on Project Server 2019?

%3CLINGO-SUB%20id%3D%22lingo-sub-2656444%22%20slang%3D%22en-US%22%3EHow%20fire%20click%20event%20once%20on%20Project%20Server%202019%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2656444%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EI%20have%20this%20%3CSTRONG%3Ejs%3A%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3Evar%20attachSaveEvent%20%3D%20setInterval(function()%20%7B%20if%20(%24(%22%23Ribbon%5C.ContextualTabs%5C.ProjectDrilldown%5C.Tasks%5C.Update%5C.PublishProject-Large%22).length%20%3D%3D%201)%20%7B%20%24('%23Ribbon%5C.ContextualTabs%5C.ProjectDrilldown%5C.Tasks%5C.Update%5C.PublishProject-Large').click(function()%20%7B%20var%20res_pwa_big%20%3D%20PWAGreetingToDb(_spPageContextInfo.userId%2C%20GetParameterValues('ProjUid'))%3B%20if%20(res_pwa_big%20%3D%3D%20'error')%20%7B%20console.log('Error%3Aon%3APublishProject-Large%3Aclick')%3B%20%7D%20%7D)%3B%20%7D%20if%20(%24(%22%23Ribbon%5C.ContextualTabs%5C.ProjectDrilldown%5C.Tasks%5C.Update%5C.PublishProject-Small%22).length%20%3D%3D%201)%20%7B%20%24('%23Ribbon%5C.ContextualTabs%5C.ProjectDrilldown%5C.Tasks%5C.Update%5C.PublishProject-Small').click(function()%20%7B%20%7B%20var%20res_pwa_small%20%3D%20PWAGreetingToDb(_spPageContextInfo.userId%2C%20GetParameterValues('ProjUid'))%3B%20if%20(res_pwa_small%20%3D%3D%20'error')%20%7B%20console.log('Error%3Aon%3APublishProject-Small%3Aclick')%3B%20%7D%20%7D)%3B%20%7D%20%7D%2C500)%3B%20%7D%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EThis%20fire%20several%20times%20%3CSTRONG%3E(2%2C3%2C5%2C...)%3C%2FSTRONG%3E.%20How%20can%20it%20fire%20once%20on%20Button%20click%3F%20If%20I%20use%20clearInterval(attachSaveEvent)%2C%20I%20can't%20fire%20second%2C%20third%20...%20click.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EBR%2C%20Vasily%3C%2FP%3E%3C%2FLINGO-BODY%3E
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