I ended up splitting things into two functions, but took a different way of
solving the problem - mainly because I don't know anything about the prototype
ajax.request function.  What I ended up doing was calling a function
recursively with setTimeout that checks to see if a certain element exists.
When it does the second function is called.  If after 10x 100 msecs the
element doesn't exist I warn the user.

I was hoping the 'onload' option of the window initialize was to set a
function to call when the window is loaded, but I couldn't get it to work.
It would be handy if that's what that option is for.

Thanks for your solution.


At 10:21 AM on Wednesday, 29 November 2006, Will Merrell wrote:
>Greg Miller wrote:
>> I'm making good progress in using PWC.  So far it works as advertised and is
>> quite easy to use.
>>
>> I've run into an issue that I don't know how to solve.  I'm creating a
>window
>> and setting the content with setAjaxContent() which works perfectly.
>However,
>> there is a <select id="notecats"> in the html being loaded, but I can't
>always
>> access it.  I've come to the conclusion that perhaps the ajax request hasn't
>> finished by the time I want to fill the <select>.
>>
>> Is there a way to either submit the ajax request synchronously, or to
>somehow
>> not continue until after the html is loaded?
>>
>
>Yes, I have had to do this a lot in my code. The trick is to split
>things into two functions. In one you issue your ajax call using the
>regular prototype ajax.request function. In the oncomplete handler you
>call your second function and pass the ajax response. In the second
>function you create your window and use the win.getContent function to
>load the content data passed from the ajax call.
>
>This may seem a little complicated, but in practice it works easily,
>since you only ever call the first function. The second is only called
>by the oncomplete of the ajax call. Conceptually, it is one function
>with a synchronous ajax call in the middle of it.
>
>HTH,
>-- Will

_______________________________________________
Javawin mailing list
[email protected]
http://mail.xilinus.com/mailman/listinfo/javawin_xilinus.com

Reply via email to