Wednesday, February 17, 2010

Update: dijit.Dialog custom control fixup

Just wanted to let you know that I've updated and improved the demoapp from yesterdays post.

The custom control is self-contained, but I recommend moving the client side script at the bottom of the source code into a javascript library.

I've implemented Mark Hughes code (thanks for the tip, Julian), which is a lot more general than my hacks.

>> Download demoapp

Let me know if you find any bugs..

5 comments:

Terry Boyd said...

First of all, thanks so much for your work in this area Tommy. I think I'm finally starting to grasp some of the important XPages concepts because of yours and other bloggers' work.

I have attempted to incorporate your work with the dijit.Dialog into my application, and everything is working perfectly...until I access the application using IE8.

When I use IE8, I get the error:

HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)

A little bit of research shows that this is due to me modifying the document while it's still being loaded. Obviously, this is within the ccModalDialogWeb script logic. However, your posted solution doesn't demonstrate the same behaviour when I access it on my server.

I believe the only difference between your solution and my own is that I have incorporated the ccModalDialog custom control within another custom control (rather than on the XPage itself). That is probably causing the error, but I can't figure out how to resolve it.

I have tried placing some code in the custom control script that calls createXSPFriendlyDialog to wait until the document is "ready" but that simply disables the logic (nothing fires at all). I had something like this:

$(document).ready(function(){ createXSPFriendlyDialog( \'' + getClientId('dialog-panel' ) + '\' ); })

Could you suggest anything else that I might be able to try?

Thanks again!

Tommy Valand said...

Did you remove the dojo.addOnLoad-line in my custom control (near the bottom in the source code)?

If not, check that you have the latest version of the demoapp. I updated it some time last week to fix the problem you're mentioning.

Terry Boyd said...

Well, I never removed it, but assume it's because I downloaded the most recent version of your demo app.

I have "sort of" resolved the issue by including "defer='defer'" in the script tag that holds the logic that calls createXSPFriendlyDialog.

Of course, that has resolved the problem with IE8, but has then led to issues with other browsers such as Firefox and Chrome:

Problem submitting an area of the page. Cannot call method 'appendChild' of null. Submit the entire page?

The facility works if I continue and submit the entire page, but obviously not an acceptable solution. I'll continue to slog on and see if I can come up with something.

Cheers!

Tommy Valand said...

If you downloaded the demoapp before friday last week (I can't remember the exact date I fixed the IE-bug), I highly recommend downloading it again/testing it in a clean environment (e.g. simple xpage with a couple of fields).

Tommy Valand said...

Just checked..

The correct nsf was last modified 18.02.10.