this will be in the next release of mootools more, but you can use it now
(just add it to your javascript):
http://github.com/mootools/mootools-more/tree/master/Source/Element/Elements.From.js

the raw file:

http://github.com/mootools/mootools-more/raw/master/Source/Element/Elements.From.js

On Sun, Sep 13, 2009 at 7:24 PM, limodou <[email protected]> wrote:

>
> 2009/9/13 Fábio M. Costa <[email protected]>:
> > 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.
> >
>
> In Jquery, you can $('<li>A Test</li>') to create a DOM element, so is
> there a similar way to do that?
>
> Why I can't use Request.HTML, because I need also other information,
> for example, I need:
>
> {'success':true, 'message':'ok', 'html':'<li>A Test</li>'}
>
> and for the second way, I also need to reget the new element from the
> container, for example:
>
> <div id='target'></div>
>
> var target = $('target');
> target.set('html', response.html + target.get('html'));
> var el = target.getFirst();
>
> But if I can :
>
> var el = xxx(response.html);
> var target = $('target');
> target.grab(el, 'top');
>
> I think this will be better.
>
> Or I can do this:
>
> var empty = new Element('div');
> empty.set('html', response.html);
> var el = empty.getFirst().clone();
> empty.dispose();
>
> --
> 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
>

Reply via email to