you are the man!

On May 3, 3:25 pm, "Jonathan Sharp" <[EMAIL PROTECTED]> wrote:
> Hi Jeff,
>
> You just need to use a closure. Outside your ajax call do $t = $(this); and
> then you can reference $t inside of your anonymous function. See below...
>
> Cheers,
> -js
>
> $(document).ready(function() {
>        $("table > tbody > tr").hover(function(){$
> (this).css("backgroundColor", "#de7121")}, function(){$
> (this).css("backgroundColor", "")}).click(function(){
>                var ordernum = $
> (this).parent().parent().prev().children(".purchaseorder").text();
>                var itemno = $(this).children(":nth-child(2)").text();
>                ordernum = ordernum.substring(ordernum.indexOf("#") + 1);
>                var $t = $(this);
>                $.ajax({
>                        type: "GET",
>                        url: "",
>                        dataType: "html",
>                        data: "action=details&po="+ordernum+"&item="+itemno,
>                        success: function(msg){
>                            $t.css('background-color', 'pink');
>                        }
>                });
>        });
>
> });
>
> On 5/3/07, Jeff <[EMAIL PROTECTED]> wrote:
>
>
>
> > I have run into a problem.  I am attachking a click() event to every
> > row of an inventory table.  When the user clicks on the row, it
> > fetches detailed information from the server and creates a new row
> > below the clicked row.  Below is the code
>
> > $(document).ready(function() {
> >        $("table > tbody > tr").hover(function(){$
> > (this).css("backgroundColor", "#de7121")}, function(){$
> > (this).css("backgroundColor", "")}).click(function(){
> >                var ordernum = $
> > (this).parent().parent().prev().children(".purchaseorder").text();
> >                var itemno = $(this).children(":nth-child(2)").text();
> >                ordernum = ordernum.substring(ordernum.indexOf("#") + 1);
> >                $.ajax({
> >                        type: "GET",
> >                        url: "",
> >                        dataType: "html",
> >                        data:
> > "action=details&po="+ordernum+"&item="+itemno,
> >                        success: function(msg){}
> >                });
> >        });
> > });
>
> > The problem is, I need to be able to pass $(this), the row that was
> > clicked, into the success callback function so that I can insert the
> > row immediately after it.  How can I accomplish this?  Thanks

Reply via email to