Re: [jQuery] How does one add children to a DOM element using jQuery?

2007-01-20 Thread Jacky

append() can add child by html/dom object.
Can u give an example?
What is your response format? html? json?

On 1/20/07, Dmitrii 'Mamut' Dimandt < [EMAIL PROTECTED]> wrote:


I'm slightly confused.

How does one add children to a DOM element using jQuery?

There are append*, prepend*, insert* methods, but none of them seem to
actually add a child *inside* a jQuery/DOM element.

Why do I need this?

I need to create a list inside a div from some data that comes, say,
from an AJAX response. How do I do that?

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





--
Best Regards,
Jacky
網絡暴民 http://jacky.seezone.net
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


[jQuery] Select third column of the table

2007-01-11 Thread Jacky

Dear all,

If I want to select the 3rd column of the table, (e.g. 3 rows)
$("tr > td:eq(2)") would returns only one .
$("tr").find("td:eq(2)") would returns 3 .

Is that ":eq(2)" is applied to the whole "tr>td" set? Is that correct?

--
Best Regards,
Jacky
網絡暴民 http://jacky.seezone.net
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Function to enumerate the querystring?

2006-11-01 Thread Jacky
The attr() returns string, not jquery object.
So you may need to pass the attribute into the query() function

On 11/1/06, Chris W. Parker <[EMAIL PROTECTED]> wrote:
> On Tuesday, October 31, 2006 10:46 AM Luke Lutman <> said:
>
> > Have a look at this recent thread :-)
> >
> http://www.nabble.com/method-plugin-for-getting-query-string-vars--tf248
> 1232.html#a6919130
>
> I read through this and tried to implement your first suggestion but I
> notice that everything takes location.search and parses that. I want to
> use it in the following way:
>
> theHref = $(this).attr("href").query();
>
> Your function is:
>
> jQuery.query = function() {
> var r = {};
> var q = location.search;
> q = q.replace(/^\?/,''); // remove the leading ?
> q = q.replace(/\&$/,''); // remove the trailing &
> jQuery.each(q.split('&'), function(){
> var key = this.split('=')[0];
> var val = this.split('=')[1];
> // convert floats
> if(/^[0-9.]+$/.test(val))
> val = parseFloat(val);
> // ingnore empty values
> if(val)
> r[key] = val;
> });
> return r;
> };
>
> I'm not sure how to modify that function to do what I want (considering
> my current lack of JS/jQuery syntax). Would you mind showing me what to
> do?
>
>
> Thank you,
> Chris.
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>


-- 
Best Regards,
Jacky
http://jacky.seezone.net

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


Re: [jQuery] Popup window reference problem

2006-10-18 Thread Jacky
So, I should:
1. includes jQuery library in popup.
2. call ref.$()
where ref is the window reference created in window.open?

On 10/19/06, Blair McKenzie <[EMAIL PROTECTED]> wrote:
> The only way I know of to use jQuery in another window/frame is to include
> jquery in that page's html, and then access it using window.$().
>
> Blair
>
>
> On 10/19/06, Jacky <[EMAIL PROTECTED]> wrote:
> >
> > I have tried to directly use the window reference.
> > i.e.
> > var abc = ref.document.getElementById("abc1");
> > abc.parentNode.removeChild(abc);
> >
> > The result is correct that the input box in popup windows being removed.
> > Seems that jQuery cannot use popup window reference?
> >
> > On 10/17/06, Jacky <[EMAIL PROTECTED]> wrote:
> > > Dear all,
> > >
> > > I would like to make a simple popup which would copy current page
> > > content and do some conversion ( e.g. text box to text). But I have met
> > > a problem of getting a wrong reference. Here is the code to
> > > demonstrate the problem:
> > >
> > > 
> > > 
> > > Test Popup
> > > 
> > > 
> > > $(document).ready(function(){
> > >
> $("#popup").click(specificPop);
> > >
> > > function specificPop(){
> > > var ref =
> genericPopup();
> > >
> $(ref.document).find("#popup_body #abc1").remove();
> > > }
> > >
> > > function
> genericPopup(){
> > > var ref =
> window.open('','','resizable=1,width=400,height=400');
> > > var diva =
> $("#diva").clone();
> > >
> ref.document.open();
> > >
> ref.document.write('<html><head><title>Popup</title></head>');
> > >
> ref.document.write ('<body id="popup_body">');
> > >
> ref.document.write($(diva).html());
> > >
> ref.document.write('</body></html>');
> > >
> ref.document.close();
> > > return ref;
> > > }
> > > });
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > >     
> > > popup
> > > 
> > > 
> > >
> > > In this example, I would expect the text box #abc1 in the popup is
> > > removed. But it removes current window's one instead. For the removal
> > > code, I have tried the following approaches:
> > >
> > > $(ref.document).find("#abc1").remove();
> > > $(ref.document).find("#popup_body #abc1").remove();
> > > $("#popup_body #abc1",ref.document).remove();
> > > $(ref.document ).find("#popup_body #abc1",ref.document).remove();
> > >
> > > but all failed. Any idea how can I can the correct reference??
> > >
> > > P.S. using jQ ver 1.0.2
> > > --
> > > Best Regards,
> > > Jacky
> > > http://jacky.seezone.net
> > >
> >
> >
> >
> > --
> > Best Regards,
> > Jacky
> > 網絡暴民 http://jacky.seezone.net
> >
> > ___
> > jQuery mailing list
> > discuss@jquery.com
> > http://jquery.com/discuss/
> >
>
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>
>
>


-- 
Best Regards,
Jacky
網絡暴民 http://jacky.seezone.net

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


Re: [jQuery] Popup window reference problem

2006-10-18 Thread Jacky
I have tried to directly use the window reference.
i.e.
var abc = ref.document.getElementById("abc1");
abc.parentNode.removeChild(abc);

The result is correct that the input box in popup windows being removed.
Seems that jQuery cannot use popup window reference?

On 10/17/06, Jacky <[EMAIL PROTECTED]> wrote:
> Dear all,
>
> I would like to make a simple popup which would copy current page
> content and do some conversion (e.g. text box to text). But I have met
> a problem of getting a wrong reference. Here is the code to
> demonstrate the problem:
>
> 
> 
> Test Popup
> 
> 
> $(document).ready(function(){
> $("#popup").click(specificPop);
>
> function specificPop(){
> var ref = genericPopup();
> $(ref.document).find("#popup_body 
> #abc1").remove();
> }
>
> function genericPopup(){
> var ref = 
> window.open('','','resizable=1,width=400,height=400');
> var diva = $("#diva").clone();
> ref.document.open();
> 
> ref.document.write('<html><head><title>Popup</title></head>');
> ref.document.write('<body 
> id="popup_body">');
> ref.document.write($(diva).html());
> ref.document.write('</body></html>');
> ref.document.close();
> return ref;
> }
> });
> 
> 
> 
> 
> 
> 
> 
> popup
> 
> 
>
> In this example, I would expect the text box #abc1 in the popup is
> removed. But it removes current window's one instead. For the removal
> code, I have tried the following approaches:
>
> $(ref.document).find("#abc1").remove();
> $(ref.document).find("#popup_body #abc1").remove();
> $("#popup_body #abc1",ref.document).remove();
> $(ref.document).find("#popup_body #abc1",ref.document).remove();
>
> but all failed. Any idea how can I can the correct reference??
>
> P.S. using jQ ver 1.0.2
> --
> Best Regards,
> Jacky
> http://jacky.seezone.net
>



-- 
Best Regards,
Jacky
網絡暴民 http://jacky.seezone.net

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


[jQuery] Popup window reference problem

2006-10-17 Thread Jacky
Dear all,

I would like to make a simple popup which would copy current page
content and do some conversion (e.g. text box to text). But I have met
a problem of getting a wrong reference. Here is the code to
demonstrate the problem:



Test Popup


$(document).ready(function(){
$("#popup").click(specificPop);

function specificPop(){
var ref = genericPopup();
$(ref.document).find("#popup_body 
#abc1").remove();
}

function genericPopup(){
var ref = 
window.open('','','resizable=1,width=400,height=400');
var diva = $("#diva").clone();
ref.document.open();

ref.document.write('<html><head><title>Popup</title></head>');
ref.document.write('<body 
id="popup_body">');
ref.document.write($(diva).html());
ref.document.write('</body></html>');
ref.document.close();
return ref;
}
});







popup



In this example, I would expect the text box #abc1 in the popup is
removed. But it removes current window's one instead. For the removal
code, I have tried the following approaches:

$(ref.document).find("#abc1").remove();
$(ref.document).find("#popup_body #abc1").remove();
$("#popup_body #abc1",ref.document).remove();
$(ref.document).find("#popup_body #abc1",ref.document).remove();

but all failed. Any idea how can I can the correct reference??

P.S. using jQ ver 1.0.2
-- 
Best Regards,
Jacky
http://jacky.seezone.net

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


Re: [jQuery] Escaping string in css selectors?

2006-10-16 Thread Jacky
Those name are generated by struts for binding collection. Just can't
avoid it. I will assign a class name for access instead.

On 10/17/06, Su <[EMAIL PROTECTED]> wrote:
> And, as with a similar question last week, those name values are just
> plain invalid:
>
> http://www.w3.org/TR/html4/types.html#type-name
>
>
>
> Blair McKenzie wrote:
> > jQuery selectors don't support escaping characters. You would be better
> > off adding a class to those inputs (e.g. "idinput") and selecting by that.
> >
> > Blair
> >
> > On 10/16/06, * Jacky* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
> > wrote:
> >
> > Is there a way to escape special character is selector?
> >
> > e.g.
> >
> > 
> > 
> > 
> > 
> >
> > say i want to select all id inputs, I should use something like
> > $("[EMAIL PROTECTED]")
> > but obviously I need to escape the ']' character.
> > --
>
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>


-- 
Best Regards,
Jacky
網絡暴民 http://jacky.seezone.net

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


[jQuery] Escaping string in css selectors?

2006-10-16 Thread Jacky
Is there a way to escape special character is selector?

e.g.






say i want to select all id inputs, I should use something like
$("[EMAIL PROTECTED]")
but obviously I need to escape the ']' character.
-- 
Best Regards,
Jacky
http://jacky.seezone.net

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


Re: [jQuery] unsuscribe

2006-10-12 Thread Jacky
If I remember correctly, the new google-group beta can also archive
mailing list. Maybe can setup one there.

On 10/12/06, Raffael Luthiger <[EMAIL PROTECTED]> wrote:
> Jan Sorgalla wrote:
> > If you want it more forum-like, check:
> > http://www.nabble.com/JQuery-f15494.html
>
> Can somebody set a link to nabble on the jQuery website?
> ( at http://jquery.com/discuss/ )
>
> Sometimes I want to search for an old comment, but since I don't use it
> that often I always forget the name nabble. And it always takes me a
> while to remember.
>
> Thanks,
> Raffael
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>



-- 
Best Regards,
Jacky
網絡暴民 http://jacky.seezone.net

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


Re: [jQuery] Appending to

2006-10-10 Thread Jacky
What I would do is just create Option object, it would do the append
automatically.

[code untested]
var routeSelect = $("#routeSelect").get(0);
routeSelect.options.length = 0; //reset to zero length
for(var i = 0; i < routes.length; ++i) {
routeSelect.options[i] = new Option(routes[i],routes[i]);
}

On 10/11/06, Klaus Hartl <[EMAIL PROTECTED]> wrote:
>
>
> Sean O schrieb:
> > Galen,
> >
> >
> > This may be of little help, but might get you pointed in the right
> > direction...
> > The following code works in FF 1.5.0.7 (PC):
> >
> >   // dummy data
> >   var routes=new Array();
> >   routes[0]="Zero";
> >   routes[1]="One";
> >   routes[2]="Two";
> >
> >   var options="";
> >   for(i = 0; i < routes.length; ++i) {
> >   options += '  ' + routes[i] 
> > +
> > '\r\n';
> >   }
> >   options += "";
> >   $("#routeselect").html(options);
> >
> > However, it bombs (empty ) in both IE6 and O9...
>
> In IE the innerHTML property for a select element is readonly, so forget
> about html() or append().
>
> You'll have to use the option constructor or document.createElement...
>
>
> -- Klaus
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>


-- 
Best Regards,
Jacky
網絡暴民 http://jacky.seezone.net

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


[jQuery] Is there a way to "endAll()"?

2006-10-09 Thread Jacky
After some find(), filter(), parent(), siblings()...,
is there any convenient way to end() back to the original $("xxx")?
This would be good for plugins to return the original jQuery object.
-- 
Best Regards,
Jacky
http://jacky.seezone.net

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


Re: [jQuery] Performance question

2006-10-07 Thread Jacky
Would caching the jQuery object a help too? Sometimes you just can't
keep the chain.

e.g. var jqObj = $("#abc");

On 10/8/06, Karl Swedberg <[EMAIL PROTECTED]> wrote:
> On Oct 7, 2006, at 3:39 PM, George Adamson wrote:
>
> > An easy performance booster is to use the second param in $() to set a
> > context for the search. Eg: $("DIV.myClass", myParentElement).
> > Perhaps this
> > is what you meant when you mentioned 'getting a parent element' ?
> >
> > Chaining methods is helpful so you can avoid re-querying. If you
> > need to put
> > other code in betwen method calls then reusing the same JQuery
> > object by
> > putting it into a variable beforehand is worth while to save
> > requerying.
> >
> > If you're going to do several queries inside the same parent element
> > (s) then
> > a combination of the above will be a big help.
>
> Those sound like good suggestions to me, though I'm no expert.
>
> Something I try to keep in mind is the relative speed of different
> types of queries. This has been mentioned on the list before, but in
> case you didn't see it, references to IDs are fastest, followed by
> elements, and then classes. At least, that's how I've understood
> previous discussions of the topic. So:
> a.  $('#my-id') is faster than $('div#my-id'), and
> b. $('div.my-class') is faster than $('.my-class')
>
> Hop that helps.
>
> Karl
> ___
> Karl Swedberg
> www.englishrules.com
> www.learningjquery.com
>
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>


-- 
Best Regards,
Jacky
網絡暴民 http://jacky.seezone.net

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


[jQuery] $.merge() can be used on object?

2006-10-06 Thread Jacky
I'm trying to do some dynamic drop down with pre-filled array. Option1
would trigger new options in Option2. Option2 would trigger new
options in Option3. (and so on...)

In matchOptions(), I would like to use $.merge to add matched items
without duplication. But it seems that it cannot be done. So I guess I
cannot use $.merge for object?

HTML:




Scripts (sorry it's a bit long):
var os = [ //options available
{f1:{value:0,label:"A1"}, f2:{value:0,label:"B1"}, 
f3:{value:0,label:"C1"}},
{f1:{value:0,label:"A1"}, f2:{value:0,label:"B1"}, 
f3:{value:1,label:"C2"}},
{f1:{value:0,label:"A1"}, f2:{value:1,label:"B2"}, 
f3:{value:2,label:"C3"}},
{f1:{value:1,label:"A2"}, f2:{value:2,label:"B3"}, 
f3:{value:3,label:"C4"}},
{f1:{value:1,label:"A2"}, f2:{value:3,label:"B4"}, 
f3:{value:4,label:"C5"}},
{f1:{value:1,label:"A2"}, f2:{value:3,label:"B4"}, 
f3:{value:5,label:"C6"}},
{f1:{value:2,label:"A3"}, f2:{value:4,label:"B5"}, 
f3:{value:6,label:"C7"}},
{f1:{value:2,label:"A3"}, f2:{value:5,label:"B6"}, 
f3:{value:7,label:"C8"}}
];
$(document).ready(function(){
$("[EMAIL PROTECTED]").dynSelect({os:os});
});

//Plugins
jQuery.fn.dynSelect = function(s){
var o = { f:"f", v:"value", l:"label", emptyMsg:"Please select...", 
os:[]};
if(s) jQuery.extend(o,s);
o.className = jQuery(this).get(0).className.replace(/\d+$/,"");
this
.each(function(i){
jQuery.dynSelect.fillOptions(this,o);
})
.change(function(){
var index = jQuery("[EMAIL 
PROTECTED]"+o.className+"]").index(this);
jQuery("[EMAIL 
PROTECTED]"+o.className+"]:gt("+index+")").each(function(){
jQuery.dynSelect.fillOptions(this,o);
});
});
}
jQuery.dynSelect = {
fillOptions: function(obj,o){
var num = obj.className.replace(o.className,"");
obj.options.length = 1;
obj.options[0] = new Option(o.emptyMsg,null);
jQuery(this.matchOptions(num,o)).each(function(i){
obj.options[i+1] = new Option(this[o.l],this[o.v]);
});
},
matchOptions: function(num,o){
var match = [];
//try to match, e.g. option3 would match by option1 and option2
jQuery.each(o.os,function(i){
var j = eval(num);
var isMatch = true;
while(--j>0){

if(jQuery("select."+o.className+j).val()!=this[o.f+j][o.v]){
    isMatch = false;
break;
}
}
if(isMatch){
match = jQuery.merge(match,[this[o.f+num]]);
}
});
return match;
}
}

-- 
Best Regards,
Jacky
http://jacky.seezone.net

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


Re: [jQuery] question on how not() works

2006-10-05 Thread Jacky
Thank you for your help~~
And yes, I'm going to match a set of checkboxes with same id prefix.
(some multiple editable row control)

On 10/5/06, John Resig <[EMAIL PROTECTED]> wrote:
> > I tried to assign an id 'checkbox' to the checkbox in the example.
> > Using not('[EMAIL PROTECTED]') result in js error in firefox:
> >
> > 'z has no properties' points to line 710 of jQuery.js (Rev: 249)
>
> Also, just using = should be sufficient. If you're trying to match a
> set of checkboxs, you should go against the @type attribute, or its
> classname, instead.
>
> --John
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>



-- 
Best Regards,
Jacky
網絡暴民 http://jacky.seezone.net

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


Re: [jQuery] question on how not() works

2006-10-04 Thread Jacky
I tried to assign an id 'checkbox' to the checkbox in the example.
Using not('[EMAIL PROTECTED]') result in js error in firefox:

'z has no properties' points to line 710 of jQuery.js (Rev: 249)


On 10/4/06, John Resig <[EMAIL PROTECTED]> wrote:
> > But in not('[EMAIL PROTECTED]@name=checkbox]') ,
> > It should read: select input element OR element with checkbox type OR
> > element named 'checkbox'.
> >
> > Is that right?
>
> .not() is the inverse of .filter()
>
> .filter("[EMAIL PROTECTED]@name=checkbox]') would be:
>
> "Is an input element AND is a checkbox AND is named checkbox"
>
> whereas .not("[EMAIL PROTECTED]@name=checkbox]') is:
>
> "Is NOT an input element AND is NOT a checkbox AND is NOT named checkbox"
>
> I guess it's not the true inverse, but you get the idea.
>
> --John
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>


-- 
Best Regards,
Jacky
網絡暴民 http://jacky.seezone.net

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


Re: [jQuery] question on how not() works

2006-10-04 Thread Jacky
So, it's a special case in not()? Just to clarify:

If I use $('[EMAIL PROTECTED]@name=checkbox]') ,
It should read: select an input element with checkbox type and named 'checkbox'.

But in not('[EMAIL PROTECTED]@name=checkbox]') ,
It should read: select input element OR element with checkbox type OR
element named 'checkbox'.

Is that right?

On 10/4/06, John Resig <[EMAIL PROTECTED]> wrote:
> .not() is really greedy, if filters out /everything/ that you specify,
> so when you say:
>
> [EMAIL PROTECTED]@name=checkbox]
>
> You're saying:
> - Anything that's not an input element
> - AND anything that's type property isn't checkbox
> - AND anything that's name isn't checkbox
>
> It's the first one that's goofing you up, in the end you can probably
> just reduce it to:
>
> .not("[EMAIL PROTECTED]")
>
> Hope this helps!
>
> --John
>
> On 10/4/06, Jacky <[EMAIL PROTECTED]> wrote:
> > Hi all,
> >
> > I'm a newbie in jQuery. I have some question on how 'not()' works. e.g.
> >
> > HTML:
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 0
> > 
> > 
> > 
> >  > name="textarea">
> > 
> > 
> > 
> >
> >
> > JS:
> > $(document).ready(function(){
> > $("#test")
> > .find("tr").find("input,select,textarea")
> > .not("[EMAIL PROTECTED]@name=checkbox]")
> >     .each(function(){
> > alert(this.name);
> > });
> > });
> >
> > What I thought was that it should find all the input,select,textara in
> >  ,remove all checkbox elements and alert their names. So I'm
> > expecting 'hidden','text','select' and 'textarea' would be alerted.
> >
> > But in reality, it will only alert 'select' and 'textarea'. Why is that??
> >
> > --
> > Best Regards,
> > Jacky
> > http://jacky.seezone.net
> >
> > ___
> > jQuery mailing list
> > discuss@jquery.com
> > http://jquery.com/discuss/
> >
>
>
> --
> John Resig
> http://ejohn.org/
> [EMAIL PROTECTED]
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>


-- 
Best Regards,
Jacky
網絡暴民 http://jacky.seezone.net

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


[jQuery] question on how not() works

2006-10-04 Thread Jacky
Hi all,

I'm a newbie in jQuery. I have some question on how 'not()' works. e.g.

HTML:











0









JS:
$(document).ready(function(){
$("#test")
.find("tr").find("input,select,textarea")
.not("[EMAIL PROTECTED]@name=checkbox]")
.each(function(){
alert(this.name);
});
});

What I thought was that it should find all the input,select,textara in
 ,remove all checkbox elements and alert their names. So I'm
expecting 'hidden','text','select' and 'textarea' would be alerted.

But in reality, it will only alert 'select' and 'textarea'. Why is that??

-- 
Best Regards,
Jacky
http://jacky.seezone.net

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