PDA

View Full Version : Window Widget - ghost form from last open



kevin_dalby
11-09-2007, 10:31 PM
1) Script Title: DHTML Window widget (v1.1)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm

3) Describe problem:
I use Codecharge 2.x. I've build a grid from the database and it creates a link with the onclick event to open the Widget Window (i'm actually using the enhanced Modal version - it's great).

When I click on the link, my window opens (IFrame mode) and I'm able to see the form i want. I can use the form, post the content, even call another page and all the action takes place in the modal window - perfect !

when i close the modal window using the X in the corner, i return to the calling page - all is well.

however, when i click the next link the modal window opens and for a few moments while the form is being fetched, the last form i had open is present on the screen.

what i'm looking for is a way, when the modal window is closed, to call some function to put a blank page in the IFrame, so when the next link is accessed - the page will be momentarily blank as the other page loads.

the Ajax method does not do this, however, i cannot manipulate forms in this type of modal window 'cause the window closes whenever i submit a form.

is there some where i can set the X to run an event like ajaxwin.load('iframe','about:blank','') as it closes the modal window?

PS - i know i can to a custom close event for a link - however - i create a single link for each record in the data grid and i can't create custom onclose events for each - unless i can reference it in the Hyperlink <A> like <a onclick=' open modal window stuff ; onclose( win.load( blank page )); ??


help,
Kevin

ddadmin
11-10-2007, 07:46 AM
So are you actually using DHTML window widget, or the modal window (http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/dhtmlmodal.htm) derivative? With the former, closing the window should already empty its contents, so opening it again shouldn't cause the last page to be shown temporarily. With the later, the code doesn't take advantage of latest changes yet...

kevin_dalby
11-10-2007, 07:09 PM
thanks !
i was using the modal version 'cause, well, it's modal - too bad it doesn't have this 'clean up' functionality - i've returned to the original window version - it'll do the trick.

is there somewhere i can trigger a refresh of the calling page (parent?) when the window is closed.

great script/widget btw !!

ddadmin
11-11-2007, 07:59 AM
is there somewhere i can trigger a refresh of the calling page (parent?) when the window is closed.

Sure. Are you looking to do this for every DHTML window opened then closed, or just a particular window instance? For the later, you could just take advantage of the "onclose" event handler for that window. For example:


var googlewin=dhtmlwindow.open("googlebox", "iframe", "http://google.com", "Google Web site", "width=700px,height=450px,resize=1,scrolling=1,center=1", "recal")

googlewin.onclose=function(){
window.location.reload()
return true
}

kevin_dalby
11-12-2007, 02:46 PM
ok, i saw that on the web site - that's straight forward when the links are static. problem is that my links are built from CodeCharge data grids, with a window open link at the front of each row...

i suppose that instead of calling dhtmlwindow.open on each link i could have the link call a 'master' function that calls the open action and has the onclose event code too....please advise, your thoughts - i'm not a sophisticated javascript coder (yet).

thanks,
kevin

ddadmin
11-12-2007, 11:19 PM
You can certainly modify the .js file so reloading the page becomes a default action on top of any custom onclose code whenever you close a window. But is that what you want though, this behavior automatically added to every DHTML window opened on the page? To do this, inside dhtmlwindow.js, find and make the changes in red below:


if (closewinbol){ //if custom event handler function returns true
window.location.reload()
if (t.state!="minimized") //if this window isn't currently minimized
"

kevin_dalby
11-13-2007, 03:46 PM
i was thinking:

** not exact syntax here **

in the rows of the data grid:
<a onclick="MyWindowOpenFunction('MyURLToOpen');"> click here </a>


at top of page:

function MyWindowOpenFunction(URLToOpen)

{
var ajaxwin=DHTMLWindow.open( parameters...., URLToOpen, parameters...);

ajaxwin.onclose() {
window.location.reload()
return true

}

do you think that'll work?

Kevin

ddadmin
11-13-2007, 11:05 PM
It should work, but didn't you mention that using the onclose event handler wasn't feasible since you'll be dealing with non "static" links?

kevin_dalby
11-13-2007, 11:11 PM
yes, however i'm building the links in each row of the data grid - so if those links call a the function i sketched out in the prev msg, can that function not define the onclose event be fired after the window is closed ?

the thing changing from row to row is only an ID that controls what data record the form in the DHTML window will fetch, the page called is static.

kd