• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

script menu action invokes itself

Engaged ,
Jan 04, 2017 Jan 04, 2017

Copy link to clipboard

Copied

Hello,

I'm wondering why my function gets called automatically when the script runs without me clicking on the menu item.

customMenuAction.addEventListener( "onInvoke", importTranslations(), false );

This runs everytime.

TOPICS
Scripting

Views

216

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Jan 04, 2017 Jan 04, 2017

because you are actually calling the function in your script - adding () after the name of any function invokes that function.

your code should be:

customMenuAction.addEventListener( "onInvoke", importTranslations, false );

Votes

Translate

Translate
Advisor ,
Jan 04, 2017 Jan 04, 2017

Copy link to clipboard

Copied

LATEST

because you are actually calling the function in your script - adding () after the name of any function invokes that function.

your code should be:

customMenuAction.addEventListener( "onInvoke", importTranslations, false );

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines