ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  PostUpdate handler problems
Posted by David Salonius on Feb-17-2012 06:25
I am assigning the onload event of the jschartviewer object (using getElementById with the clientid).  I use this event to determine when the chart has completed loading so I can do some other actions before displaying it (using my own image).  I also am assigning a PostUpdate event handler for the same chart for when partialupdate is used instead of streamupdate.  I use partialupdate for setting marks and zooms, while streamupdate for standard updating.

When the PostUpdate event handler is called, it seems to be removing the onload event handler I have previously assigned.  After using partialupdate, the onload event no longer fires for that particular chart object.  In IE, I can capture the calling object in this method by using the event.srcElement and reassign the onload event which works.   But this doesn't work in Firefox as it doesn't seem like the event is being passed in to the function as an argument.  I've tried setting the function like this:

JsChartViewer.get('" + l_wcv.ClientID + "').attachHandler('PostUpdate', function(ev) { userInputComplete(ev) });

and I've tried:

JsChartViewer.get('" + l_wcv.ClientID + "').attachHandler('PostUpdate', userInputComplete);

Both execute the userInputComplete function on the PostUpdate event, but I get "ev" is not defined in the first example.  I have tried using ev and event without success.

My code to parse the event object looks like this and is verified to work in both IE and Firefox as long as the event is being passed in for Firefox.

    ev = ev || window.event;
    var obj = (ev.srcElement) ? ev.srcElement : ev.target;

In your docs, you mention that "this" can be used to reference the calling object, but that doesn't seem to work for me in either IE or Firefox.

Thanks for any help.

  Re: PostUpdate handler problems
Posted by David Salonius on Feb-17-2012 22:34
I found a way to make it work.

Inside of my PostUpdate event handler function, I used the following code.

var obj = document.getElementById(this.getId());
obj.onload = complete;

That reassigned the onload event and solved my problem.

If you have anything to add in regards to why the onload event handler is being removed when partialupdate is called (possibly only with a postupdate handler), let me know.

Thanks.

  Re: PostUpdate handler problems
Posted by Peter Kwan on Feb-17-2012 23:16
Hi David,

In a partialUpdate, ChartDirector will attach its own onload, onerror and onabort handler to the <IMG> tag, as it too needs to know when the chart has been loaded in order to generate the PostUpdate event. This should have overwritten your onload handler. Reestablishing the onload handler in the PostUpdate event should be a workable method. Another method is to use attachEvent (for IE) or addEventListener (or FireFox/Chorme/Safari) to attach your handler to the <IMG> tag instead of assigning to the onload attribute.

In the PostUpdate event, the "this" pointer points to the object that generates the event, which is the JsChartViewer object (not the DOM object representing the <IMG> tag). If you need to get the <IMG> tag, you may use JsChartViewer.getId to obtain the id of the underlying <IMG> tag, and then use getElementById to get the DOM object representing the <IMG> tag.

Hope this can help.

Regards
Peter Kwan