AJAX / YUI

Location: BlogsComments    
Posted by: Dale Friday, January 16, 2009
Points of interest I've come across integrating AJAX(YUI) with my apps.

AJAX: Don't forget that when making AJAX calls and loading new content which contains new javascript and new css that this new code is *added* to the existing code. An example which hit me was loading an array of functions that run when the page load is complete. However every time I called an AJAX page this array was becoming longer and longer as the same functions where added, and called over and over again.

JavaScript Error c00ce56e on IE7: Likely to be a encoding naming problem, see http://support.microsoft.com/default.aspx?scid=kb;en-us;304625.

Widget.Dialog Reuse: The behaviour of the Dialog control is inconsistent when reusing. For reliable behaviour destroy the old and create a new one. May apply to other container based controls as well.

Widget.Dialog.destroy(): I couldn't get this to work, it gave me error "oButton.tagName is undefined - container.debug. js (line 7045)". In the end I did the following which is a bit of a hack but hopefully does the job without memory leaks.

myDialog = null;
var temp = document.getElement ById(myDialogDiv Id + "_c"); // myDialogDivId = DIV ID passed into Dialog constructor
document.body. removeChild( temp);

Widget.Dialog active content: Loading content into the Dialog control doesn't automatically execute it. e.g. if loading with content that contains javascript in some browsers it will not run. One solution is http://www.bubbling-library.com/eng/api/docs/plugins/dispatcher.

Widget.Dialog & Widget.Panel Together: I use the Dialog control to display a form and the Panel control to show a 'Please Wait' box while the form is reloading. However at one point I was showing the Panel before the Dialog had been hidden and that caused me a recursion problem.

Widget.Dialog form handling: When submitting a form, if the response contains a form which is to be loaded into a Dialog control as well then ensure that the response is a correctly formed HTML document otherwise HTML strips the form out when you load it into the Dialog control. The strange thing was that this didn't happen when obtaining the document manually using the connection class, only when as a response to an automatic form post in the Dialog control - I thought they used the same mechanisms underneath but maybe not. Its a bit of a pain really, because sometimes one wants to load a portion of a document rather than the whole thing, and since its being inserted into the DOM it soon becomes a complete document. IE7 would appear to be expecting a *proper* XML/HTML document from which it removes the root note.Also note that when sending a response back to the Dialog control that different browsers again translate the document differently. IE7 turns \n\r into a whitespace which initially had me confused as I was splitting the return by line break.

Permalink |  Trackback

Your name:
Title:
Comment:
Add Comment   Cancel