waxmiguelito / iui

Automatically exported from code.google.com/p/iui
MIT License
0 stars 0 forks source link

[PATCH] iUI addOnLoad #204

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Load a HTML file with a default selected iUI page. This functions as a
splash screen, since there are some big js files to be loaded.
2. After the js is loaded (in this case using dojo.addOnLoad), call
iui.showPageById on the next page (a loginpage).
3. A blank page shows up, since the load handler of dojo was not executed
yet when the showpage was called.

I propose a patch, similar to the dojo addOnLoad mechanism. In this case
you can call iui.addOnLoad and the function you provide is either called
immediately if iui is already loaded, or after the load handler is executed
completely.

It could even be user internally for calls to showPage if iui is not loaded
yet, so a user doesn't have to worry himself when he can start calling that
function.

Original issue reported on code.google.com by hendrik@van-antwerpen.net on 16 Dec 2009 at 4:26

Attachments:

GoogleCodeExporter commented 9 years ago
That's a pretty clean patch -- thanks!  Is it a patch against 0.31 or 
0.40-dev1?  There is some event support in 
0.40 that this might be an extension to.  If  we define an "iuiload' event, we 
could just call send 
sendEvent("iuiload", body)...

Original comment by msgilli...@gmail.com on 16 Dec 2009 at 7:09

GoogleCodeExporter commented 9 years ago
This patch is against a recent mercurial version. Sending an event at the end 
of the load handler would 
also be a solution. Maybe that's more consistent with the rest of iui.

Original comment by hendrik@van-antwerpen.net on 16 Dec 2009 at 11:48

GoogleCodeExporter commented 9 years ago
The advantage of this method over an event is that is saves the user 
administration on the state of iui. 
Now you just call addOnLoad and your sure the function is executed as soon as 
possible. Otherwise you 
have to implement this yourself, based on the event.

Original comment by hendrik@van-antwerpen.net on 17 Dec 2009 at 12:40

GoogleCodeExporter commented 9 years ago
I don't know how patach acceptance works normally. Is there anything more to be 
done, 
before this could be included?

Original comment by hendrik@van-antwerpen.net on 28 Dec 2009 at 1:42

GoogleCodeExporter commented 9 years ago
It should be possible to combine the event mechanism with immediately running 
the function.  The would 
result in less code and a structure similar to the other callbacks, but would 
also have the advantage you 
mention of just calling iui.addOnLoad to guarantee your function is called.

I would also recommend starting a discussion on the iui-developers  list about 
this patch and alternatives to 
see what comments and/or improvements others may have.

A sample and/or a test for the patch would also be great.

I think having a mechanism like this is essential to supporting plugins which 
is the focus of release 0.40.  I'd 
like to get something included soon.

Original comment by msgilli...@gmail.com on 28 Dec 2009 at 8:56

GoogleCodeExporter commented 9 years ago
It would be nice to have a hook that will call a function before iUI is loaded 
AND another for after iUI is loaded...

Original comment by msgilli...@gmail.com on 10 Feb 2010 at 4:09

GoogleCodeExporter commented 9 years ago
Hendrik, do you have a use case for when a user will be calling addOnLoad and 
will not be sure of the state of 
iUI.  I can think of two use cases
1) During page loading register a function to be called after content loaded 
BUT BEFORE iUI is initialized
2) During page loading register a function to be called after content is 
loading AND AFTER iUI is initialized

I'm getting ready to put in some code to address this issue (we used your patch 
for iuiPad, btw -- I also noticed 
that you were playing with iScroll back in January, I'd be interested in 
knowing what you found)

Original comment by msgilli...@gmail.com on 25 Apr 2010 at 4:17

GoogleCodeExporter commented 9 years ago
Hendrik's patch is in an Hg clone:
http://code.google.com/r/hendrikvanantwerpen-iui/source/detail?r=4f52314330055f7
c308f9631c650117a25c79e30

Original comment by msgilli...@gmail.com on 25 Apr 2010 at 4:29

GoogleCodeExporter commented 9 years ago
I think the second use-case is important.
For example: on pageload you start initializing your application, which uses 
iUI to
show pages. If you call iUI before it's onload is called, things won't work. To
prevent this, inject a call to addOnLoad somewhere in my initialization 
sequence to
make sure that iUI is loaded before you continue.

About iScroll: It looks pretty nice, but iPhone Safari behaves strange when you 
start
touch events on form inputs. Basically no events (neither touch events nor 
timers)
are fired until you let go. This makes it nearly impossible to implement a 
generic
scrolling solution which works well with forms.

Original comment by hendrik@van-antwerpen.net on 26 Apr 2010 at 8:47