[jQuery] Re: jQuery-way for filtering self + all children
FYI... There is an open enhancement ticket that proposes adding an optional selector to the .andSelf() method. http://dev.jquery.com/ticket/4446 -- Brandon Aaron On Mon, May 4, 2009 at 5:11 PM, Pappy helga...@gmail.com wrote: Just curious... what's the jQuery-way of saying Give me all children that match a filter and include myself if I happen to match as well.? I've been using - element.find(*).andSelf().filter([myfilter]) but that seems kludgy. Is there a better way? If not, I'll just wrap this as findInclusive or find([filter], true) or something.
[jQuery] Re: jQuery-way for filtering self + all children
While it will be nice to pass in a selector to andSelf, it's a shame you'll have to repeat the selector in both the 'find' and 'addSelf'. I'd still rather there be only one function necessary. It's an awfully common pattern. Honestly, I wish 'find' had been this way from the start, and there was a descendants function that works like 'find' today... it seems much more sane to me. Hmm... other possible interfaces/names - jObject.search(selector) jObject.findAll(selector) jObject.findInclusive(selector) // my favorite jObject.find(selector, andSelf) On May 4, 4:47 pm, Brandon Aaron brandon.aa...@gmail.com wrote: FYI... There is an open enhancement ticket that proposes adding an optional selector to the .andSelf() method.http://dev.jquery.com/ticket/4446 -- Brandon Aaron On Mon, May 4, 2009 at 5:11 PM, Pappy helga...@gmail.com wrote: Just curious... what's the jQuery-way of saying Give me all children that match a filter and include myself if I happen to match as well.? I've been using - element.find(*).andSelf().filter([myfilter]) but that seems kludgy. Is there a better way? If not, I'll just wrap this as findInclusive or find([filter], true) or something.
[jQuery] Re: jQuery-way for filtering self + all children
Yeah, I see what you mean. What about .findAndSelf(selector)? Trying to stick with existing naming conventions... Do you have some sample scenarios to go along with this need? Like actual HTML, etc. Would you mind filing a new enhancement ticket for this? http://dev.jquery.com/newticket -- Brandon Aaron On Mon, May 4, 2009 at 6:57 PM, Pappy helga...@gmail.com wrote: While it will be nice to pass in a selector to andSelf, it's a shame you'll have to repeat the selector in both the 'find' and 'addSelf'. I'd still rather there be only one function necessary. It's an awfully common pattern. Honestly, I wish 'find' had been this way from the start, and there was a descendants function that works like 'find' today... it seems much more sane to me. Hmm... other possible interfaces/names - jObject.search(selector) jObject.findAll(selector) jObject.findInclusive(selector) // my favorite jObject.find(selector, andSelf) On May 4, 4:47 pm, Brandon Aaron brandon.aa...@gmail.com wrote: FYI... There is an open enhancement ticket that proposes adding an optional selector to the .andSelf() method.http://dev.jquery.com/ticket/4446 -- Brandon Aaron On Mon, May 4, 2009 at 5:11 PM, Pappy helga...@gmail.com wrote: Just curious... what's the jQuery-way of saying Give me all children that match a filter and include myself if I happen to match as well.? I've been using - element.find(*).andSelf().filter([myfilter]) but that seems kludgy. Is there a better way? If not, I'll just wrap this as findInclusive or find([filter], true) or something.
[jQuery] Re: jQuery way
From the link you posted you have a library clash going on. Scriptaculous 1.5.1 conflicts with jQuery, even a basic ID query is not working correctly. prototype which is also included also seems to be broken. On Jan 5, 1:21 pm, Ricardo Tomasi ricardob...@gmail.com wrote: For some reason I was sure you were French! hehe :D In the HTML you posted, everything is inside the #header div. #menu_lateral_usuario and #footer are not children of #container, they are way deeper into the DOM tree. Since everything is contained by #header, it doesn't need to be excluded. The way to achieve what you want you have to also exclude all the element's parent's and inner children: var conteudo = $('#menu_lateral_usuario, #footer'); $(#container *).not(conteudo).not(conteudo.parents()).not (conteudo.find('*')).empty(); That seems to work with the HTML on pastebin. the page at barquettenet.net is timing out. abraço - ricardo On Jan 5, 3:53 am, Dirceu Barquette dirceu.barque...@gmail.com wrote: Hi Ricardo, Thats right! I know it works. But not with the dirty code of my job, both doesn't work... You are from Brazil like me. Don't you? See the project at:http://calango.barquettenet.net/~dirceu/cva //login:dirceu, password:senha you can click at Adicionar projetos. I injected jQuery at this link. My goal is bypass the dirty code, but... arg. using firebug, change the second index of array to menu_lateral_usuario. It seems like this: var a = $('#container')[0]; var arr = [header,menu_lateral_usuario,footer]; jQuery.each(a.childNodes,function(k,v){ if (jQuery.inArray(v.id,arr) 0){ $(v).empty(); } }) The above code works (imediatly after login...), but: $(#container).children().not(#header, #content, #footer).empty(); //JResig code and $(#container :not(#header, #content, #footer)).empty(); //Kean code Both these very clean codes doesn't work... I don't know why, but can help me in the future. You know for my poor english. I really appreciate your help to explain this problem. We can chat at gmail if you wish... Very special thanks to all! Dirceu Barquette 2009/1/5 Ricardo Tomasi ricardob...@gmail.com Both ways do work, as demonstrated here: http://jsbin.com/eruje/ On Jan 4, 5:53 pm, Dirceu Barquette dirceu.barque...@gmail.com wrote: Thanks a lot! But it doesn't works... :-( I get a really dirty code to add modules. I wish inject a pretty good jQuery code, but is impossible!!! thanks your attention! Dirceu Barquette 2009/1/4 John Resig jere...@gmail.com Maybe: $(#container).children().not(#header, #content, #footer).empty(); --John On Sun, Jan 4, 2009 at 2:05 PM, Dirceu Barquette dirceu.barque...@gmail.com wrote: Hi all! Is there better way? var elem = $('#container')[0]; var arr = [header,content,footer]; jQuery.each(elem.childNodes,function(k,v) { if (jQuery.inArray(v.id, arr) 0) { $(v).empty(); } }) thanks Dirceu Barquette
[jQuery] Re: jQuery way
For some reason I was sure you were French! hehe :D In the HTML you posted, everything is inside the #header div. #menu_lateral_usuario and #footer are not children of #container, they are way deeper into the DOM tree. Since everything is contained by #header, it doesn't need to be excluded. The way to achieve what you want you have to also exclude all the element's parent's and inner children: var conteudo = $('#menu_lateral_usuario, #footer'); $(#container *).not(conteudo).not(conteudo.parents()).not (conteudo.find('*')).empty(); That seems to work with the HTML on pastebin. the page at barquettenet.net is timing out. abraço - ricardo On Jan 5, 3:53 am, Dirceu Barquette dirceu.barque...@gmail.com wrote: Hi Ricardo, Thats right! I know it works. But not with the dirty code of my job, both doesn't work... You are from Brazil like me. Don't you? See the project at:http://calango.barquettenet.net/~dirceu/cva //login:dirceu, password:senha you can click at Adicionar projetos. I injected jQuery at this link. My goal is bypass the dirty code, but... arg. using firebug, change the second index of array to menu_lateral_usuario. It seems like this: var a = $('#container')[0]; var arr = [header,menu_lateral_usuario,footer]; jQuery.each(a.childNodes,function(k,v){ if (jQuery.inArray(v.id,arr) 0){ $(v).empty(); } }) The above code works (imediatly after login...), but: $(#container).children().not(#header, #content, #footer).empty(); //JResig code and $(#container :not(#header, #content, #footer)).empty(); //Kean code Both these very clean codes doesn't work... I don't know why, but can help me in the future. You know for my poor english. I really appreciate your help to explain this problem. We can chat at gmail if you wish... Very special thanks to all! Dirceu Barquette 2009/1/5 Ricardo Tomasi ricardob...@gmail.com Both ways do work, as demonstrated here: http://jsbin.com/eruje/ On Jan 4, 5:53 pm, Dirceu Barquette dirceu.barque...@gmail.com wrote: Thanks a lot! But it doesn't works... :-( I get a really dirty code to add modules. I wish inject a pretty good jQuery code, but is impossible!!! thanks your attention! Dirceu Barquette 2009/1/4 John Resig jere...@gmail.com Maybe: $(#container).children().not(#header, #content, #footer).empty(); --John On Sun, Jan 4, 2009 at 2:05 PM, Dirceu Barquette dirceu.barque...@gmail.com wrote: Hi all! Is there better way? var elem = $('#container')[0]; var arr = [header,content,footer]; jQuery.each(elem.childNodes,function(k,v) { if (jQuery.inArray(v.id, arr) 0) { $(v).empty(); } }) thanks Dirceu Barquette
[jQuery] Re: jQuery way
Hi Brian, This is a real code. I can't modify it cause not my code: http://pastebin.com/m2e4cf3ea Thanks for help! Dirceu Barquette
[jQuery] Re: jQuery way
Maybe: $(#container).children().not(#header, #content, #footer).empty(); --John On Sun, Jan 4, 2009 at 2:05 PM, Dirceu Barquette dirceu.barque...@gmail.com wrote: Hi all! Is there better way? var elem = $('#container')[0]; var arr = [header,content,footer]; jQuery.each(elem.childNodes,function(k,v) { if (jQuery.inArray(v.id, arr) 0) { $(v).empty(); } }) thanks Dirceu Barquette
[jQuery] Re: jQuery way
This might be shorter. $(#container :not(#header, #content, #footer)).empty(); - Kean Tested with Sizzle but not jQuery 1.2.6 On Jan 4, 11:08 am, John Resig jere...@gmail.com wrote: Maybe: $(#container).children().not(#header, #content, #footer).empty(); --John On Sun, Jan 4, 2009 at 2:05 PM, Dirceu Barquette dirceu.barque...@gmail.com wrote: Hi all! Is there better way? var elem = $('#container')[0]; var arr = [header,content,footer]; jQuery.each(elem.childNodes,function(k,v) { if (jQuery.inArray(v.id, arr) 0) { $(v).empty(); } }) thanks Dirceu Barquette
[jQuery] Re: jQuery way
Thanks a lot! But it doesn't works... :-( I get a really dirty code to add modules. I wish inject a pretty good jQuery code, but is impossible!!! thanks your attention! Dirceu Barquette 2009/1/4 John Resig jere...@gmail.com Maybe: $(#container).children().not(#header, #content, #footer).empty(); --John On Sun, Jan 4, 2009 at 2:05 PM, Dirceu Barquette dirceu.barque...@gmail.com wrote: Hi all! Is there better way? var elem = $('#container')[0]; var arr = [header,content,footer]; jQuery.each(elem.childNodes,function(k,v) { if (jQuery.inArray(v.id, arr) 0) { $(v).empty(); } }) thanks Dirceu Barquette
[jQuery] Re: jQuery way
Not works too... Thank you. Dirceu Barquette 2009/1/4 Kean shenan...@gmail.com This might be shorter. $(#container :not(#header, #content, #footer)).empty(); - Kean Tested with Sizzle but not jQuery 1.2.6 On Jan 4, 11:08 am, John Resig jere...@gmail.com wrote: Maybe: $(#container).children().not(#header, #content, #footer).empty(); --John On Sun, Jan 4, 2009 at 2:05 PM, Dirceu Barquette dirceu.barque...@gmail.com wrote: Hi all! Is there better way? var elem = $('#container')[0]; var arr = [header,content,footer]; jQuery.each(elem.childNodes,function(k,v) { if (jQuery.inArray(v.id, arr) 0) { $(v).empty(); } }) thanks Dirceu Barquette
[jQuery] Re: jQuery way
Both ways do work, as demonstrated here: http://jsbin.com/eruje/ On Jan 4, 5:53 pm, Dirceu Barquette dirceu.barque...@gmail.com wrote: Thanks a lot! But it doesn't works... :-( I get a really dirty code to add modules. I wish inject a pretty good jQuery code, but is impossible!!! thanks your attention! Dirceu Barquette 2009/1/4 John Resig jere...@gmail.com Maybe: $(#container).children().not(#header, #content, #footer).empty(); --John On Sun, Jan 4, 2009 at 2:05 PM, Dirceu Barquette dirceu.barque...@gmail.com wrote: Hi all! Is there better way? var elem = $('#container')[0]; var arr = [header,content,footer]; jQuery.each(elem.childNodes,function(k,v) { if (jQuery.inArray(v.id, arr) 0) { $(v).empty(); } }) thanks Dirceu Barquette
[jQuery] Re: jQuery way
Hi Ricardo, Thats right! I know it works. But not with the dirty code of my job, both doesn't work... You are from Brazil like me. Don't you? See the project at: http://calango.barquettenet.net/~dirceu/cva//login:dirceu, password:senha you can click at Adicionar projetos. I injected jQuery at this link. My goal is bypass the dirty code, but... arg. using firebug, change the second index of array to menu_lateral_usuario. It seems like this: var a = $('#container')[0]; var arr = [header,menu_lateral_usuario,footer]; jQuery.each(a.childNodes,function(k,v){ if (jQuery.inArray(v.id,arr) 0){ $(v).empty(); } }) The above code works (imediatly after login...), but: $(#container).children().not(#header, #content, #footer).empty(); //JResig code and $(#container :not(#header, #content, #footer)).empty(); //Kean code Both these very clean codes doesn't work... I don't know why, but can help me in the future. You know for my poor english. I really appreciate your help to explain this problem. We can chat at gmail if you wish... Very special thanks to all! Dirceu Barquette 2009/1/5 Ricardo Tomasi ricardob...@gmail.com Both ways do work, as demonstrated here: http://jsbin.com/eruje/ On Jan 4, 5:53 pm, Dirceu Barquette dirceu.barque...@gmail.com wrote: Thanks a lot! But it doesn't works... :-( I get a really dirty code to add modules. I wish inject a pretty good jQuery code, but is impossible!!! thanks your attention! Dirceu Barquette 2009/1/4 John Resig jere...@gmail.com Maybe: $(#container).children().not(#header, #content, #footer).empty(); --John On Sun, Jan 4, 2009 at 2:05 PM, Dirceu Barquette dirceu.barque...@gmail.com wrote: Hi all! Is there better way? var elem = $('#container')[0]; var arr = [header,content,footer]; jQuery.each(elem.childNodes,function(k,v) { if (jQuery.inArray(v.id, arr) 0) { $(v).empty(); } }) thanks Dirceu Barquette
[jQuery] Re: jQuery way
What does #container look like? Can you post an example of just that element with its HTML? On Mon, Jan 5, 2009 at 12:53 AM, Dirceu Barquette dirceu.barque...@gmail.com wrote: Hi Ricardo, Thats right! I know it works. But not with the dirty code of my job, both doesn't work... You are from Brazil like me. Don't you? See the project at: http://calango.barquettenet.net/~dirceu/cva//login:dirceu, password:senha you can click at Adicionar projetos. I injected jQuery at this link. My goal is bypass the dirty code, but... arg. using firebug, change the second index of array to menu_lateral_usuario. It seems like this: var a = $('#container')[0]; var arr = [header,menu_lateral_usuario,footer]; jQuery.each(a.childNodes,function(k,v){ if (jQuery.inArray(v.id,arr) 0){ $(v).empty(); } }) The above code works (imediatly after login...), but: $(#container).children().not(#header, #content, #footer).empty(); //JResig code and $(#container :not(#header, #content, #footer)).empty(); //Kean code Both these very clean codes doesn't work... I don't know why, but can help me in the future. You know for my poor english. I really appreciate your help to explain this problem. We can chat at gmail if you wish... Very special thanks to all! Dirceu Barquette 2009/1/5 Ricardo Tomasi ricardob...@gmail.com Both ways do work, as demonstrated here: http://jsbin.com/eruje/ On Jan 4, 5:53 pm, Dirceu Barquette dirceu.barque...@gmail.com wrote: Thanks a lot! But it doesn't works... :-( I get a really dirty code to add modules. I wish inject a pretty good jQuery code, but is impossible!!! thanks your attention! Dirceu Barquette 2009/1/4 John Resig jere...@gmail.com Maybe: $(#container).children().not(#header, #content, #footer).empty(); --John On Sun, Jan 4, 2009 at 2:05 PM, Dirceu Barquette dirceu.barque...@gmail.com wrote: Hi all! Is there better way? var elem = $('#container')[0]; var arr = [header,content,footer]; jQuery.each(elem.childNodes,function(k,v) { if (jQuery.inArray(v.id, arr) 0) { $(v).empty(); } }) thanks Dirceu Barquette
[jQuery] Re: jquery way to set page title?
No need for jquery here, using normal javascript would be much faster. document.title = blahblahblah; (i think :-\ ) On 6/1/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, Subject line is the question. How do I use JQuery to set the page title (what goes in the TITLE tags)? Thanks, - Dave
[jQuery] Re: jquery way to set page title?
Interestingly $(title).text('new'); changes the title in the DOM, you can see it in firebug, but it doesn't change it in the window. Glen On 6/1/07, Sean Catchpole [EMAIL PROTECTED] wrote: jQuery is not needed for this, try: document.title = ...; ~Sean