Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8001479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:06:05+00:00 2026-06-04T16:06:05+00:00

I have two Javascript files, that I will significantly streamline to simplify the issue

  • 0

I have two Javascript files, that I will significantly streamline to simplify the issue in hand.

form.js

function open_action_dialog(){
   // code to open the dialog..

   // If [Return] is pressed when focus is on the #action field, call the action confirmation function defined in the second javascript file.
   $('#action').keypress(function(e){
      var fn_name = "action_confirm";
      if(e.which == 13)
         window[fn_name]();
   });
}

blog.form.js

$(function (){
   $("#dialog_action_open").click(function() { 
       open_action_dialog(); 
   });

   function action_confirm(){
     alert('action confirmed');
     return;
   }
});

So on my page I have a button with id dialog_action_open when clicked opens the action dialog; this is a function from the second file successfully calling a function from the first file.

Inside the dialog, there’s an input text field with id action where I’ve set it so that if the user presses [Return] when their cursor is focused on the field, it should call the action_confirm() function defined in the second file. It does pickup the keypress event, but does not call the function from the second file; inside Google’s code inspector, the error is:

Uncaught TypeError: Property ‘action_confirm’ of object [object Window] is not a function

So, my question is what do I need to do to be able to successfully call the function from the second file from inside a function in the first file? Keeping in mind, I’m aware you can’t immediately call a function defined later. But, even though my action_confirm() function is defined after the function calling it from the first file, isn’t this technicality moot considering the call is occurring AFTER the page has loaded, and more specifically AFTER a click event on the page?

I would appreciate being enlightened.

Many thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:06:06+00:00Added an answer on June 4, 2026 at 4:06 pm

    Because the function you’re trying to call is wrapped in another function, it’s invisible to the function in your other JS.

    You could remove $(function (){ (and it’s closing }); )

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a code that will allow FlowPlayer to retrieve a Javascript array and
I have two files. location.php, that outputs this: [[javascript],[PHP]] and in another file: <script
I have two arrays. A list of urls to JavaScript files that I am
I have created two JavaScript files. One file is "validators.js" and the other is
I have two asp.net textboxes and need to put a validate function in javascript
Possible Duplicate: JavaScript: formatting number with exactly two decimals Now that I have got
I have designed a stylesheet/javascript files bundler and minifier that uses a simple cache
What I'm trying to accomplish: I have two base files on my server that
I have two JavaScript arrays: var array1 = [Vijendra,Singh]; var array2 = [Singh, Shakya];
Hy, I have two options to choose from: Client side(with FLASH or Javascript): pro:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.