This topic is locked
[SOLVED]

 Firing change events in the javascript onload

10/1/2016 3:56:21 PM
PHPRunner General questions
S
steveh author

I have various handlers for hiding and showing fields.
These are defined in the onload javascript event and I also use control.fireEvent("change") to initially fire them and set the starting point for the controls.
The downside to this is that the page is then marked as modified so the user is prompted when they hit back to list.
So at the end of the onload I set the page as not modified.
pageObject.setPageModified(false);
However, the events have not run at this point, they have merely been inserted in the event queue.
I guess my options are either to put this in a customer event and queue that, or run the queue.
Has anybody come across this, any ideas on the best option?

romaldus 10/2/2016



I have various handlers for hiding and showing fields.
These are defined in the onload javascript event and I also use control.fireEvent("change") to initially fire them and set the starting point for the controls.
The downside to this is that the page is then marked as modified so the user is prompted when they hit back to list.
So at the end of the onload I set the page as not modified.
pageObject.setPageModified(false);
However, the events have not run at this point, they have merely been inserted in the event queue.
I guess my options are either to put this in a customer event and queue that, or run the queue.
Has anybody come across this, any ideas on the best option?


it's hard to undestand without screenshots or sample code

S
steveh author 10/3/2016



it's hard to undestand without screenshots or sample code


No disrespect but if you've never used those calls or understand how the event queues in the runner javascript classes work then I'm not sure that the code will help, here's an example.
Here's an example:-
var myCtrl = Runner.getControl(pageid, 'myID');

var proxystub=proxy.myID; // Get the list of values and field states
myCtrl.on('change', function() {
//

// Handle the change of myID

//
var ID = this.getValue(); // Get the ID

bdlHandleChange(ID,pageObj,proxystub,inlineRow,pageid);

}

); // End of the on event
// Now handle the current value

myCtrl.fireEvent('change');
// Set the page as not changed (we may have fired change events)

pageObj.setPageModified(false);
The issue is that the events are queued in the event queue in RUnnerAll.js and the setPageModified call is run immediately, whereas the myCtrl.fireEvent is queued so actually runs after this.
Regards

Steve

Admin 10/5/2016

Use setTimeout() function to fire an event independently?

S
steveh author 10/5/2016

Perfect, thanks