Arrix,

Thanks for the reply.  So, in an ajax response snippet, does it make
the most sense just to make javascript calls directly.  Could there be
an issue with the DOM in the response snippet not being fully loaded
before the script functions are called.  I tried doing something like
this in the response snippet but it doesn't work:
<div id='some_div'>
   <input type='button' id='preview' value='Preview'/>
</div>
<script type="text/javascript">

  //<![CDATA[
  $('#preview').load(function() {
    $j('#preview').click(function() {
      $j('#confirmation').show()
    });
   });
   alert('Hi')
  //]]>
</script>

Now just doing this and it works but I am worried that #preview may
not be guaranteed to be loaded before the javascript calls:
<script type="text/javascript">
  //<![CDATA[
    $j('#preview').click(function() {
      $j('#confirmation').show()
    });
   alert('Hi')
  //]]>
</script>


On Sep 30, 1:48 am, Arrix <[EMAIL PROTECTED]> wrote:
> document.ready won't trigger anymore after the page has been loaded. 
> Seehttp://dev.jquery.com/ticket/904
> So avoid $(document).ready() in ajax response snippet.
>
> new function() {
>     alert('Hi')
>  }
>
> You are actually creating a new instance using an anonymous constructor. The
> constructor is invoked while evaluating the argument for ready().
>
> On 9/29/07, Curtis Spencer <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Hi,
>
> > I have a page that makes an Ajax request that gets a a snippet of html
> > that includes the following tag:
> > <script type="text/javascript">
> >   //<![CDATA[
> >   $j(document).ready(function() {
> >      alert('Hi')
> >   });
> >   //]]>
> > </script>
>
> > Nothing happens in this case.  However, if i change the tag to this:
> > <script type="text/javascript">
> >   //<![CDATA[
> >   $j(document).ready(new function() {
> >      alert('Hi')
> >   });
> >   //]]>
> > </script>
>
> > The alert happens.  Can someone please illustrate the difference, and
> > why the first one doesn't work?  All the examples I see of $
> > (document).ready never has the new in front of function.  Also, is
> > this the right way to call jquery from an ajax response.  The parent
> > doesn't necessarily know what is going on in this child, so I can't
> > put it in the success handler of the ajax get call.
>
> > Thanks,
> > Curtis
>
> --
> Arrix

Reply via email to