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 */
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
classNamewhen you bind the event handler, you can just take advantage of the closure:On the other hand: I see you’re using a custom event. So, if you have a call to
.triggeranywhere else on your code, then you can pass anything as the second argument, and it will be passed to the event handler: