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 9232083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:13:44+00:00 2026-06-18T06:13:44+00:00

Using PhpStorm: My code is passing a Instantiated Class as a Parameter into a

  • 0

Using PhpStorm: My code is passing a Instantiated Class as a Parameter into a function. I know that className is a reference to a particular class. But is there anyway to let my code become aware of what ClassName is?

   $(document).on('validSelection', function(event,className){
      alert( className.sayHello() );
   });

This would really make coding this particular function a lot easier since I plan on using ClassName a lot. In php, you can force the recognition by do somethings like:

/* @var $variable ClassName */
  • 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-18T06:13:45+00:00Added an answer on June 18, 2026 at 6:13 am

    My code is passing a Instantiated Class as a Parameter into a function

    No, it isn’t. You just added another parameter to the function’s list, but when it’s called (by jQuery, when the event happens), it’s not passed. If you have access to className when you bind the event handler, you can just take advantage of the closure:

    var className = {
        sayHello : function() {
           return "hello";
        }
    };
    $(document).on('validSelection', function(event){
       alert(className.sayHello()); // works
    });
    

    On the other hand: I see you’re using a custom event. So, if you have a call to .trigger anywhere else on your code, then you can pass anything as the second argument, and it will be passed to the event handler:

    var className = {
        sayHello : function() {
           return "hello";
        }
    };
    $(document).trigger('validSelection', className);
    
    // On a separate scope...
    
    $(document).on('validSelection', function(event, className){
       alert(className.sayHello()); // works
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using PHPStorm and have written a class that utilises the SimpleXML class.
I am using phpStorm to edit a file. This code breaks the page: $(#delete_all_button).click(function(){
I am using a PhpStorm IDE, and only in one particular file, it started
I'm using JetBrains PHPStorm but I believe this question relates to the other JetBrains
By using the inspect code tool of PHPStorm I get the following message: 'recipient_user.id
Using CMake I want to check if a particular function (cv::getGaborKernel) from OpenCV library
I am using PHPStorm 4.0.3 and I'm working a project that includes JSP files.
I'm a rather happy PhpStorm user, but there are a few things that really
I'm using PHP Storm as my IDE, but I believe that other IDE's such
I'm currently using PHPStorm 6 EAP build and git, but answer to this question

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.