Re: [jQuery] Feature Request for $(expr, context)

2006-11-27 Thread Jörn Zaefferer
Mathias Bank schrieb:
> Thanks for your answers. This helps.
>
> But I think, that the feature request is still interesting, because it
> makes using jQuery more consistent. With this behaviour, it doesn't
> matter, if I have an element in DOM or I have just an element in
> memory.
>   
Right, if $(html).find("li") is possible, there is no reason why $("li", 
html) shouldn't work as well.
I created a bug report for this matter: http://jquery.com/dev/bugs/bug/443/

-- 
Jörn Zaefferer

http://bassistance.de


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Feature Request for $(expr, context)

2006-11-27 Thread Mathias Bank
Thanks for your answers. This helps.

But I think, that the feature request is still interesting, because it
makes using jQuery more consistent. With this behaviour, it doesn't
matter, if I have an element in DOM or I have just an element in
memory.

Mathias

2006/11/27, Jörn Zaefferer <[EMAIL PROTECTED]>:
> Mathias Bank schrieb:
> > Until know, I have to create a dom element like
> >
> > $('body').append('');
> > $('#helper').html(html);
> > $('#helper li',html).css("color","red");
> > html = $('#helper').html();
> > $('#helper').remove();
> >
> How about this:
> html = $(html).find("li").css("color", "red").html();
>
> Looks good for me, jQury already takes the burden from you to create the
> helper.
>
> --
> Jörn Zaefferer
>
> http://bassistance.de
>
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Feature Request for $(expr, context)

2006-11-27 Thread Jörn Zaefferer
Mathias Bank schrieb:
> Until know, I have to create a dom element like
>
> $('body').append('');
> $('#helper').html(html);
> $('#helper li',html).css("color","red");
> html = $('#helper').html();
> $('#helper').remove();
>   
How about this:
html = $(html).find("li").css("color", "red").html();

Looks good for me, jQury already takes the burden from you to create the 
helper.

-- 
Jörn Zaefferer

http://bassistance.de


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Feature Request for $(expr, context)

2006-11-27 Thread Linan Wang

Hi Mathias,

It's an interesting idea. I think the better way to implement it is to using
DocumentFragment.
Codes:

var fragment=document.createDocumentFragment();
fragment.innerHTML=html;
$(exp,fragment).whatever_youlike_function




On 11/24/06, Mathias Bank <[EMAIL PROTECTED]> wrote:


Hi,

$(expr, context) is a really nice function, but it could be optimized.
Until now, it can only be used, if context is a dom tree. But see this
scenario:

var html='';
html += "";
for (var i=0; i<10;i++) {
  html += "listing "+i+"";
}
html+='';

Now, it would be great, if you could apply every jQuery function like
$('li',html).css("color", "red");

Until know, I have to create a dom element like

$('body').append('');
$('#helper').html(html);
$('#helper li',html).css("color","red");
html = $('#helper').html();
$('#helper').remove();


That does not look good at all. Is there a way to realize this
behaviour in jQuery-Core?


Mathias

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/





--
Best regards

Linan Wang
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Feature Request for $(expr, context)

2006-11-24 Thread Choan C. Gálvez
On 11/24/06, Mathias Bank <[EMAIL PROTECTED]> wrote:
> Hi,
>
> $(expr, context) is a really nice function, but it could be optimized.
> Until now, it can only be used, if context is a dom tree. But see this
> scenario:
>
> var html='';
> html += "";
> for (var i=0; i<10;i++) {
>   html += "listing "+i+"";
> }
> html+='';
>
> Now, it would be great, if you could apply every jQuery function like
> $('li',html).css("color", "red");

You can create a "Document tree" using the `$` function:

var foo = $("blah").find("p").css("color", "red").end();

Then append it to any element you want to:

$(document.body).append(foo);

> Until know, I have to create a dom element like
>
> $('body').append('');
> $('#helper').html(html);
> $('#helper li',html).css("color","red");
> html = $('#helper').html();
> $('#helper').remove();
>
>
> That does not look good at all. Is there a way to realize this
> behaviour in jQuery-Core?

Using the method described above your code can be simplified to:

$(html).find("li").css("color", "red").end().appendTo("#someSelector");

-- 
Choan


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


[jQuery] Feature Request for $(expr, context)

2006-11-24 Thread Mathias Bank
Hi,

$(expr, context) is a really nice function, but it could be optimized.
Until now, it can only be used, if context is a dom tree. But see this
scenario:

var html='';
html += "";
for (var i=0; i<10;i++) {
  html += "listing "+i+"";
}
html+='';

Now, it would be great, if you could apply every jQuery function like
$('li',html).css("color", "red");

Until know, I have to create a dom element like

$('body').append('');
$('#helper').html(html);
$('#helper li',html).css("color","red");
html = $('#helper').html();
$('#helper').remove();


That does not look good at all. Is there a way to realize this
behaviour in jQuery-Core?


Mathias

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/