[ace] onload event

1,366 views
Skip to first unread message

Zhomart

unread,
Jan 9, 2012, 12:21:13 AM1/9/12
to Ajax.org Cloud9 Editor (Ace)
Hello,

I found that there is no event 'onload'. And I want to create this
event myself, but I don't know how to do it.

Because somewhere internet is slow, while ace loading users think
that
it is hung or it wont work.

I want to create loading progress. and hide it when "onload" event of
ace is called. (When ace completely loaded)

Is it possible to make 'onload' event for ace ?

Michael Yagudaev

unread,
Apr 23, 2012, 12:18:32 PM4/23/12
to ace-d...@googlegroups.com
I would also really like to know the answer to this question as  I want to do something similar.

Harutyun Amirjanyan

unread,
Apr 23, 2012, 12:44:31 PM4/23/12
to ace-d...@googlegroups.com
ace doesn't do any async loading by itself
so this depends on the way you are loading ace
if you use minified script included into page then it will be loaded with page
if you use require or something to download script on demand it's easy
to get load event from that

ace.edit just creates editor synchronousely

Michael Yagudaev

unread,
Apr 26, 2012, 11:38:28 AM4/26/12
to ace-d...@googlegroups.com
A follow up would be is there an event firing when the editor is finally ready for user input? If not, should there be one?

Ace does apply some styling to the DOM element it is invoked on. It looks kinda ugly to have a FOUC (Flash of Unstyled Content). One thing we have yet to try is something simple like:  http://www.learningjquery.com/2008/10/1-way-to-avoid-the-flash-of-unstyled-content. But maybe we should have an entry on the wiki that describes how to easily avoid the problem with Ace in particular.

Harutyun Amirjanyan

unread,
Apr 26, 2012, 2:28:30 PM4/26/12
to ace-d...@googlegroups.com
once your javascript calling ace.edit is finished editor will be ready for input
FOUC happens between rendering and the time you call ace.edit
and the best way to not have it is to not put content into element,
and add it later with js

theres also some loading if you call editor.setTheme("my/not/loaded/theme")
but it's better to load default theme with ace.js before calling ace.edit

Michael Yagudaev

unread,
Apr 27, 2012, 12:45:58 AM4/27/12
to ace-d...@googlegroups.com
Thank you for the quick reply, this really helps clear things up :)
Reply all
Reply to author
Forward
0 new messages