Monday, July 27, 2009

[jQuery] Re: after together with load

Figured it out, for those interested:

$(document.createElement('tr'))
      .load('http://localhost:8080/admin/?page=moretabletest')
      .insertAfter('.c_row' + i);



On Mon, Jul 27, 2009 at 9:30 PM, avrono <avronolshewsky@gmail.com> wrote:
Hi,

I am trying to dynamically load html into a table, i.e add new rows in
the table if a user clicks on an element in the table.

Calling code :

<TD><a href="#" onClick="javascript:AddElement('someVal',
'someOtherval');return false;">Click ME</a></TD>

No problems there, I have a function :

function AddElement(someval, i) {

       $('.mytable').load("http://www.someURL.com/?page=moretabletest");

}

I have tried using the .after method (I am not sure if that is the
right terminology).

       $('.mytableRow').after('<tr><td></td></tr>);        // Works !

This works fine , however I cannot figure out how to use .load()
and .after together. I.e instead of hard coded HTML to add , I want to
add HTML into my table from a GET to the server.

Any ideas ?

No comments: