I think the problem was that I was attaching the event listener to the
main element in the fragment. so I that didn't work because I was
attaching it to an element that doesn't exist yet in the main page
code. On the main page it looked something like:
var myFragElement=document.getElementById('element');
myFrag.addEventListener('load', function(event) {
doSomethingWhenFragLoads()
});
- Scott
On Nov 25, 1:12 am, Sean Gilligan <[email protected]> wrote:
> Scott Finkelstein wrote:
> > I was actually intrigued by the second example on this page (Ajax
> > Link). I see that you are storing that ajax panel (minus the toolbar)
> > in a file called "fragPanel.frag" thus bringing that separate section
> > into the framework.
>
> .frag is just a convention that I use for serving incomplete HTML from
> static files. They could be dynamically generated by PHP or any
> server-side technology and can have any extension.
>
> > So assuming I need to run a javascript from within one of these .frag
> > files,
> > is there an event
> > listener I can call when the .frag file is brought in to the main
> > view?
>
> Yes. There are beforeInsert and afterInsert events that you can use.
> There is an event logger sample that demonstrates how to use
> them:http://code.google.com/p/iui/source/browse/web-app/iui/js/iui-event-l...
>
> There also have been several patches submitted for earlier versions of
> iUI that have various mechanisms to run JavaScript that is loaded in a
> fragment. I added the events to iui.js so that any of these mechanisms
> could be used without the need to modify iui.js itself.
>
> See:http://code.google.com/p/iui/issues/detail?id=102http://code.google.com/p/iui/issues/detail?id=128
>
> > I tried both 'aftertransition' and 'load' with no success.
>
> Hmm. You probably should have been able to get it work using "load" as
> well (with the only issue being that your code might be called more than
> once) What was the problem?
>
> -- Sean
--
You received this message because you are subscribed to the Google Groups
"iPhoneWebDev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/iphonewebdev?hl=en.