omg... your right putting on a div wont work, the tr and th tags will get removed. Thanks Aaron.
-- Fábio Miranda Costa Solucione Sistemas Front-End Engineer http://meiocodigo.com On Thu, Sep 10, 2009 at 12:39 PM, Aaron Newton <[email protected]> wrote: > Unfortunately, this won't work quite right because you're dealing with > table elements. You're creating a div and setting it's html to the response > html, but the problem is that many browsers will wrap table fragments in > table and tbody tags. You don't want that. > You can use the new Elements.from method that's coming in the next version > of MooTools More: > > > http://github.com/mootools/mootools-more/blob/master/Source/Element/Elements.From.js > > If you include that, then you can do: > > onSuccess: function(responseText){ > var elements = Elements.from(responseText); > elements.inject($('id_from_tr'), 'after'); // or 'before' > } > > 2009/9/10 Fábio M. Costa <[email protected]> > >> To do this without Request.HTML you would need to get the response and set >> the html of a div then grab all the childElements from this div, now you >> have the same as responseTree from the request.HTML. >> >> with Request: >> onSuccess: function(responseText){ >> var tmpDiv = new Element('div', {'html': responseText}); >> var responseTree = tmpDiv.getChildren(); >> >> responseTree.inject($('id_from_tr'), 'after'); // or 'before' >> } >> >> >> >> -- >> Fábio Miranda Costa >> Solucione Sistemas >> Front-End Engineer >> http://meiocodigo.com >> >> >> 2009/9/10 Fábio M. Costa <[email protected]> >> >> Hmm got it. >>> Then you will need Request.HTML. It will transform you response into html >>> then you just get the row you want and inject the new nodes that came from >>> the responseTree and injectAfter or before it. >>> something like this: >>> >>> onSuccess: function(responseTree){ >>> $$(responseTree).inject($('id_from_tr'), 'after'); // or 'before' >>> } >>> >>> >>> -- >>> Fábio Miranda Costa >>> Solucione Sistemas >>> Front-End Engineer >>> http://meiocodigo.com >>> >>> >>> On Thu, Sep 10, 2009 at 5:49 AM, darpi <[email protected]> wrote: >>> >>>> >>>> Thanks Fàbio, >>>> I'd like to inject the rows in a table (tbody and thead) >>>> already populated, so the table is already created in the DOM. >>>> So the inject would be after a row already present. >>>> This--> $('id_of_tbody_or_thead').set('html', responseText); would add >>>> a row to a table but not to a specific position in the table, for >>>> example after row with id='dsdds' or not? >>>> >>>> So If I'd like to add a row from plain text with TH tags at a specific >>>> location how can I do? >>>> >>>> Thanks, Dario >>>> >>>> On Sep 9, 5:50 pm, Fábio M. Costa <[email protected]> wrote: >>>> > You can insert this into a valid table that is still inserted into the >>>> DOM. >>>> > So you would do someting like: >>>> > >>>> > $('id_of_tbody_or_thead').set('html', responseText); >>>> > >>>> > Note that as i said the tbody or thead should be still into the DOM >>>> into a >>>> > table, or as you said you will lose the 'th' tags. >>>> > >>>> > -- >>>> > Fábio Miranda Costa >>>> > Solucione Sistemas >>>> > Front-End Engineerhttp://meiocodigo.com >>>> > >>>> > On Wed, Sep 9, 2009 at 12:40 PM, darpi <[email protected]> wrote: >>>> > >>>> > > Dear All, >>>> > > maybe is a silly question, but I can't figure out how to >>>> > > have an element from a responseText from Request. >>>> > > I know that I can use request.html, but this can help me better >>>> > > understand some html/javascript/mootools activities. >>>> > >>>> > > I receive for example from a request this code: >>>> > > <tr><th>mutuls</th><th>you are welcome</th></tr> >>>> > > <tr><th>mutuls2</th><th>you are welcome 2</th></tr> >>>> > > <tr><th>mutuls3</th><th>yoou are welcome again</th></tr> >>>> > >>>> > > In the request.... >>>> > > onSuccess: function(responseText, responseXML) { >>>> > >>>> > > I'd like to inject these rows inside an exiting table after an >>>> > > element. >>>> > >>>> > > It would be: >>>> > > myresponseTextElement.inject(myTableRow,'after') >>>> > >>>> > > The question is: how obtain myresponseTextElement from responseText? >>>> > >>>> > > var myresponseTextElement=new Element('tr') >>>> > > myresponseTextElement.set('html',responseText); >>>> > > This way I loose all <th> tags. >>>> > >>>> > > Any suggestions??? >>>> > >>>> > > } >>>> > >>>> > > Thanks, Dario >>>> > >>>> > >>>> >>> >>> >> >
