javascript - JS - 'before' EventListeners are firing AFTER the event -


see comments @ bottom of post - i've come partial solution

i'm attempting write simple js script force users spell check indesign documents before actions (specifically save, saveas, , export).

please bare me i'm learning js, i'm sure there easy i'm missing.

essentially, issue script working, running after event. example, on saveas, event runs, saves document, , triggers function.

i'm thinking need sort of before.invoke, can't figure out.

here code far:

#target indesign  #targetengine "session"  main(); function main(){     alert('hello 8');      var mybeforesaveevlist = app.addeventlistener("beforesave", checkspelling, false);      var mybeforesaveasevlist = app.addeventlistener("beforesaveas", checkspelling, false);      var mybeforeexportevlist = app.addeventlistener("beforeexport", checkspelling, false);      //var myaftersaveevlist = app.addeventlistener("aftersave", myaftersavehandler, false);      function checkspelling(myevent){         alert('before save...');         app.menuactions.item("check spelling...").invoke();     }  } 

i managed come partial solution, i'm running issue.

i called actions name , added 'beforeinvoke' event listener. allows checkspelling function run before event run.

the issue save/export dialog box pops after check spelling popup, never allowing user check spelling before saving/exporting.

i imagine need write code prevent dialog box popping until spell checking done, i'm not sure start.

new code:

main();                function main(){                     alert('hello 12');                 //app.addeventlistener( "beforeexport", chspelling );         //app.addeventlistener( "beforesave", chspelling );         //app.addeventlistener( "beforesaveas", chspelling );                   var      	//beforesave = app.menuactions.itembyid ( 260 ).addeventlistener ( "beforeinvoke", checkspelling );      	//beforesaveas = app.menuactions.itembyid ( 261 ).addeventlistener ( "beforeinvoke", checkspelling );      	//beforesaveascopy = app.menuactions.itembyid ( 262 ).addeventlistener ( "beforeinvoke", checkspelling );      	//beforeexport = app.menuactions.itembyid ( 113411 ).addeventlistener ( "beforeinvoke", checkspelling );      	      	beforesave = app.menuactions.itembyname ( "$id/save" ).addeventlistener ( "beforeinvoke", checkspelling );      	beforesaveas = app.menuactions.itembyname ( "$id/save as..." ).addeventlistener ( "beforeinvoke", checkspelling );      	beforesaveacopy = app.menuactions.itembyname ( "$id/save copy..." ).addeventlistener ( "beforeinvoke", checkspelling );      	beforeexport = app.menuactions.itembyname ( "$id/export..." ).addeventlistener ( "beforeinvoke", checkspelling );                    function checkspelling(myevent){        		alert('check spelling...');       		app.menuactions.item("check spelling...").invoke();        	 }                      }  


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -