AHAH!

Not sure if it was the return false, or clearing up a php error in the
return (which I could not see until I removed the display: none -
DUH!) but it is working now!!!!

Thanks for your help!!!


On Mar 25, 2:10 pm, James <james.gp....@gmail.com> wrote:
> I don't see the issue, but I do see something that might affect it.
> Try:
>
>         $(".vieworderdata").live("click",function() {
>                 $(".order_logs1").show("slow");
>                 return false;  // <-- added this line
>         });
>
> Since you're clicking on a <a> link, the "return false" tells the
> browser not to follow-through with the actual action of clicking the
> <a> link (which is, go to href="#").
> Other than that, it looks fine. If you remove the "display:none"
> from .order_logs1, does it display as expected?
>
> On Mar 24, 1:58 pm, iskills <i...@infiniteskills.com> wrote:
>
> > Thanks James - that helps quite a bit!
>
> > I am now able to execute an alert, using the .live function for the
> > added elements on the page.
>
> > The issue I am now having is that the display of the order_logs
> > element will not "show".  Do I need to do another .live call on that?
> > I am a bit confused now ;)
>
> > <div class="dlorder">
> >         <span class="orderid"><a href="#" title="1" 
> > class="vieworderdata">1</
> > a></span>
> >         <span class="orderdate">2009-03-24</span>
> >         <span class="name">123 - wiget</span>
> >         <div style="display: none" class="order_logs1">
> >                 <span class="access_key">Access Key: 3452</span>
> >                 <div class="log">
> >                         <span class="log_date">2009-23-04 10:00"04</span>
> >                         <span class="log_ip">0.0.0.0</span>
> >                         <span class="disk_no">Disk Number: 1</span>
> >                 </div>
> >         </div>
> > </div>
>
> > That is the return data from that original AJAX call again, and this
> > is the "new" javascript:
> > $(document).ready(function(){
> >         $("#sboid").click(function(){
> >                 
> > $("#search_results").load("/cart/admin/files/ajax.html",{order_id:$
> > ('#orderid').val(),action:"digital_search"});
> >         });
> >         $(".vieworderdata").live("click",function() {
> >                 $(".order_logs1").show("slow");
> >         });
>
> > });
>
> > So I have the .live function for the click, and if I do an alert in
> > that call, it executes.  However, the .show does not in this case...
>
> > Is it again, something in the formatting of the elements, or am I
> > missing something else here....
>
> > Thanks again!
>
> > On Mar 24, 6:39 pm, James <james.gp....@gmail.com> wrote:
>
> > > The issue is that once you bind a click handler on existing elements,
> > > it will not take effect on elements added in the future. You can re-
> > > bind it again once you added the new content, or you can use jQuery's
> > > live() function in place of click() to have elements added in the
> > > future to also have the event attached. This is good since once you
> > > call it on page load, you don't have to call it 
> > > again.http://docs.jquery.com/Events/live
>
> > > Another possible issue with your code is your use of element IDs. You
> > > can only have one unique ID on one HTML page at any time. If you keep
> > > clicking on "more", you're going to have many 'vieworderdata' IDs, and
> > > that's not valid. To offset this issue, use the "class" attribute
> > > instead, as you can have more than one element with the same class
> > > attribute on a page. Then change your click binding to use
> > > the .myClass instead of #myID.
>
> > > Another minor issue is that your should use double-quotes for your
> > > element attributes in HTML.
> > > Instead of:
> > > <div id='dlorder'>
>
> > > use:
> > > <div id="dlorder">
>
> > > On Mar 24, 11:08 am, iskills <i...@infiniteskills.com> wrote:
>
> > > > OK - let me please preface this by the fact that I am now 12 hours
> > > > into jQuery, with a pretty basic Javascript understanding, and years
> > > > of PHP work.  I could not find the answer to my questions, mostly
> > > > because I don't exactly know how to frame them!
>
> > > > I am creating a search with expandable results.  The search part I
> > > > have down just fine, I have a form submit button that executes a .load
> > > > function that drops the search results to a div.  So far so good -
> > > > this works wonders.  Now, what I am trying to accomplish and cannot,
> > > > is for a linked item in that returned data, to then show/hide
> > > > additional data passed through to it in a hidden div.
>
> > > > So my javascript is this:
> > > > $(document).ready(function(){
> > > >         $("#sboid").click(function(){
> > > >                 
> > > > $("#search_results").load("ajax.html",{order_id:$('#orderid').val
> > > > (),action:"digital_search"});
> > > >         });
> > > >         $("#vieworderdata").click(function() {
> > > >                 $("#order_logs").show("slow");
> > > >         });
>
> > > > });
>
> > > > The return from the ajax.html page would be something like:
> > > > <div id='dlorder'>
> > > >         <span id='orderid'><a href='#' 
> > > > id='vieworderdata'>1234</a></span>
> > > >         <span id='orderdate'>2009-03-24</span>
> > > >         <span id='name'>4456 - widget</span>
> > > >         <div style='display: none' id='order_logs'>
> > > >                 <span id='access_key'>Access Key: absdcef</span>
> > > >                 <div id='log'>
> > > >                         <span id='log_date'>2009-03-24 10:00:02</span>
> > > >                         <span id='log_ip'>0.0.0.0</span>
> > > >                         <span id='disk_no'>Disk Number: 1</span>
> > > >                 </div>
> > > >         </div>
> > > > </div>
>
> > > > That gets returned into the     <div id='search_results'></div> in the
> > > > starting HTML page.
>
> > > > So, when I click on the a href in the returned data, in theory, that
> > > > hidden block will be displayed.  Not happening.  I am not sure if I am
> > > > not accessing it properly in the javascript above, or if it is not
> > > > working because it was not a part of the original page DOM, and cannot
> > > > be accessed?
>
> > > > Further to this, once THAT is working, there is an issue that there
> > > > may be MANY results returned, and how to reference the "a href" that
> > > > was clicked, to the hidden div to be displayed.  I can easily return
> > > > different div names, appending a running count to them
> > > > (vieworderdata1, vieworderdata2, vieworderdata3, etc), but how to
> > > > create the javascript code to say "the one I clicked on here is the
> > > > div hidden just below it..."
>
> > > > TIA for your help, and please go easy on a noob ;)

Reply via email to