Focal Point
[SOLVED]What are these?

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2497085086

February 03, 2016, 10:31 AM
MattC
[SOLVED]What are these?
When you add an Event in App Studio, it add these. Are these necessary or just examples?

 
var eventObject = event ? event : window.event;
var ctrl = eventObject.target ? eventObject.target : eventObject.srcElement;
 



 


//Begin function lnkDefaultDate_onclick
function lnkDefaultDate_onclick(event) {
var eventObject = event ? event : window.event;
var ctrl = eventObject.target ? eventObject.target : eventObject.srcElement;


} 

 

This message has been edited. Last edited by: <Emily McAllister>,


WebFOCUS 8.1.05
February 03, 2016, 11:30 AM
Squatch
They are not needed most of the time. When a JavaScript event happens, a collection of information about the event is sent to the function. It is stored in the variable "event" that you see in parentheses.

Some of this information is extracted out for you in the two lines below the start of the function.

There are also functions packaged up in the "event" variable (Well, technically it's called an "object"). A few months ago I needed to call on one of these functions.

I had a situation where a user needed to pick a date range, but I needed to do a validity check on the range before the dates got sent to a FEX file. My validation happens when the user clicks a submit button.

So in the button's click event, if the date range is determined to be invalid, I use this code to stop the FEX from being called on:

  alert("Incomplete Discharge date range");
  event.stopImmediatePropagation();
  return;

The "stopImmediatePropagation" is a function that aborts the normal program flow that would result in the FEX file being called and working with a bad date range.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
February 03, 2016, 04:00 PM
MattC
Thanks for the explanation. I normally remove those and everything seems to work ok.


WebFOCUS 8.1.05