How do I make sure the external page is fully loaded before I try to
bind events to it?

On Nov 24, 9:43 am, Michel Belleville <michel.bellevi...@gmail.com>
wrote:
> You can use live as soon as your page can execute JavaScript as far as I'm
> aware, though if you mix the approaches (live can't do everything bound
> events can do, for exemple catching a form submission as for now) you'd
> probably stay on the safer side doing everything once the page is fully
> loaded.
>
> Michel Belleville
>
> 2009/11/24 Rockinelle <ericbles...@gmail.com>
>
> > Ok the live technique worked, thanks! I understand the idea of binding
> > it after the documents is loaded. Is that more than a matter of
> > binding it after the ajax call, or *must* I use .live so that it waits
> > for the page to load before binding?
>
> > On Nov 24, 6:17 am, bhu Boue vidya <bhuvi...@yahoo.com.au> wrote:
> > > i think its because you are binding the handler to a DOM element
> > > before it exists
>
> > > if you use the 'live' method you may get what you want
>
> > > ie
>
> > > $().ready(function() {
> > >     $('#submit1').live('click', function() {
> > >         alert('it works!');
> > >     });
>
> > > });
>
> > > alternately, bind the event handler *after* the content is loaded via
> > > ajax
>
> > > On Nov 24, 7:39 am, Rockinelle <ericbles...@gmail.com> wrote:
>
> > > > I am jumping into ajax with Jquery and I have what I think is an easy
> > > > question. I have successfully used jquery load to bring an external
> > > > php doc into my page. That page has a form on it where I want to use
> > > > jquery to reload that external page to reload with ajax when the form
> > > > is submitted. What I need to know is where to put the code to act on
> > > > the external form. Do I place the code on the page .load ing the
> > > > external form or do I need to place it on the external form?
>
> > > > I've tried it both ways and I can't get it to work.
> > > > For testing I'm just doing something simple
> > > > $(document).ready(function(){
> > > >                 $('#submit1').click(function(){
> > > >                         alert('It works!');
> > > >                 });
> > > >         });
> > > > This code does work when it's located on the external form and I load
> > > > that form explicitly rather than through an ajax call. What am I
> > > > missing?
>
> > > > I guess my question has a greater scope than just this example. Will
> > > > javascript on a main page act on selectors that match those in a div
> > > > that's loaded through ajax? The same question with CSS too.

Reply via email to