In this case you could use Request.HTML. It would give you an li node and you would just do:
target.grab(response.elements, 'top'); http://mootools.net/docs/core/Request/Request.HTML Both the ways you showed are fine, but i would do number 2 just because its faster. Still you could do number 1 in a shorter way: var item = new Element('li', {html: response.html}); target.grab(item, 'top); As the second parameter of the Element constructor you can pass an object with any property that you can use with the 'set' method from Element (styles, events, html ....). Cya. -- Fábio Miranda Costa Solucione Sistemas Front-End Engineer http://meiocodigo.com On Sun, Sep 13, 2009 at 6:05 AM, limodou <[email protected]> wrote: > > Say I want to return a HTML code snippet, just like: <li>A list</li>. > And I want to inert it to an element. But it's a text. So how to > insert it to an element? > > I thought the way: > > 1. Only return "A list" , and say it'll be returned in response.html, and > do : > > var item = Element('li'); > item.set('html', response.html); > target.grab(item, 'top); > > But I don't like this very much. > > 2. Still return the whole HTML code "<li>A list</li>", and do: > > target.set('html', response.html+target.get('html')); > > I don't know which is the simple and best way, and are there other > ways to do what I want? > > Thanks. > > -- > I like python! > UliPad <<The Python Editor>>: http://code.google.com/p/ulipad/ > UliWeb <<simple web framework>>: http://uliwebproject.appspot.com > My Blog: http://hi.baidu.com/limodou >
