Re: [jQuery] Fast form serializer function for review
Nice. You could simplify this: var f = ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON']; $(f.join(','), this).each(function() { to: var f = 'INPUT,TEXTAREA,SELECT,BUTTON'; $(f, this).each(function() { BTW, what do you mean when you say it isn't a plugin? Looks like one to me. :-) -Mike From: Matt Grimm I've put together a fast form serializer function that I'm hoping can get some review from the list for completeness, bugs, a better name, etc. A previous thread revealed quite a performance issue with the form plugin's existing serialize function when operating on a form with a large number of elements. My plugin sacrifices semantic order for wicked speed. I have a test form with a select menu containing 500 options -- with the current serializer, it takes around 5 full seconds to do the job, and with mine, it takes about 50 ms. Any feedback would be much appreciated, including whether you think this should be included with the form plugin distribution. Since this isn't a plugin, I'm just going to include the source in this message -- please let me know if there's a better (i.e., more polite) way to do this. Thanks! m. --- $.fn.fastSerialize = function() { var a = []; var f = ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON']; $(f.join(','), this).each(function() { var n = this.name || this.id; var t = this.type; if (!n || this.disabled || t == 'reset' || (t == 'checkbox' || t == 'radio') !this.checked || (t == 'submit' || t == 'image' || t == 'button') this.form.clicked != this || this.tagName == 'SELECT' this.selectedIndex == -1) return; if (t == 'image' this.form.clicked_x) return a.push( {name: n+'_x', value: this.form.clicked_x}, {name: n+'_y', value: this.form.clicked_y} ); if (t == 'select-multiple') { $('option', this).each( function() { if (this.selected) a.push({name: n, value: this.value || $(this).text()}); }); return; } a.push({name: n, value: this.value}); }); return a; }; ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Chainable if/else - hot or not?
Hi, I don't know, I've been using .filter( foo, Function ) and .find( foo, Function ) for a while now and I find them to be immensely useful - especially considering that they're non-destructive. Well, if it was destructive it would be more consistent. I don't think that it would be a problem, because you always have end(): $('.hideme').hide().filter('.showme').show().end().addclass('IamCrazy'); is currently equivalent to $('.hideme').hide().filter('.showme', function() { $(this).show(); }).addclass('IamCrazy'); It feels a bit odd to me. I'd expect this to be equal to the first line: $('.hideme').hide().filter('.showme', function() { $(this).show(); }).end().addclass('IamCrazy'); The Problem arises when chaining a lot of filter(), find(), etc. functions. Then your way is IMO less readable. How about shortcut-functions for e.g. filter().end(): $.fn.filterend = function(s,c) { return this.filter(s,c).end(); } $('.hideme').hide().filterend('.showme', function() { $(this).show(); }).addclass('IamCrazy'); I think that would be less confusing. Just my 2 cents. Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Fast form serializer function for review
Matt Grimm schrieb: I've put together a fast form serializer function that I'm hoping can get some review from the list for completeness, bugs, a better name, etc. A previous thread revealed quite a performance issue with the form plugin's existing serialize function when operating on a form with a large number of elements. My plugin sacrifices semantic order for wicked speed. I have a test form with a select menu containing 500 options -- with the current serializer, it takes around 5 full seconds to do the job, and with mine, it takes about 50 ms. Any feedback would be much appreciated, including whether you think this should be included with the form plugin distribution. AFAIK the form plugin pretended to send the form as if it was a normal submit. While I haven't seen a problem with the order yet, I see a problem with this: $('option', this).each( function() { if (this.selected) a.push({name: n, value: this.value || $(this).text()}); }); If the user submits a option value=Please select.../option, I want the empty value to be submitted, not the text. Apart from that, nice work. I wonder if we could reduce the overall code by merging both seriliaze methods. -- Jörn ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Fast form serializer function for review
Matt Grimm schrieb: Hello, I've put together a fast form serializer function that I'm hoping can get some review from the list for completeness, bugs, a better name, etc. A previous thread revealed quite a performance issue with the form plugin's existing serialize function when operating on a form with a large number of elements. My plugin sacrifices semantic order for wicked speed. I have a test form with a select menu containing 500 options -- with the current serializer, it takes around 5 full seconds to do the job, and with mine, it takes about 50 ms. Any feedback would be much appreciated, including whether you think this should be included with the form plugin distribution. Since this isn't a plugin, I'm just going to include the source in this message -- please let me know if there's a better (i.e., more polite) way to do this. Thanks! m. Please make it XHTML as XML compatible (hm, why is it always me complaining about that?)...: ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] For Brandon Aaron
Hi, Quite interesting might be the leak pattern page at msdn: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ietechcol/ dnwebgen/ie_leak_patterns.asp Does someone know of a similiar ressource for Firefox, or is finding memory leaks here more by chance? That link suggests (as you might have guessed before) that IE uses simple refference-counting for garbage collection. That is not a very good decission for a language like JavaScript where circular are not too exotic. I am not shure, but AFAIK the Mozilla-framework uses the sport model garbage collector, which doesn't have such a problem. If a Mozilla-browser leaks memory there are two possible reasons. One is that of course there can be bugs in the GC-implementation, and the other one can be memory-fragmentation. Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Fast form serializer function for review
Klaus Hartl schrieb: Please make it XHTML as XML compatible (hm, why is it always me complaining about that?)...: There's missing a part, I'm sorry, please normalize tag names: var f = ['input', 'textarea', 'select', 'button']; and this.tagName.toLowerCase() == 'select' Thank you, Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Single Value Attributes
John Resig schrieb: $.fn.checked = function(b) { if ( b ) this.attr( checked, checked ); else this.removeAttr( checked ); }; What do you think? How about this: $.fn.checked = function(b) { if( typeof b == 'boolean') { if(b) { this.attr('checked, 'checked'); } else { this.removeAttr('checked'); } else { return this.attr('checked'); } } Could then be categorized within DOM/Attributes, as it aligns nicely with the rest of the set/get methods. -- Jörn ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Chainable if/else - hot or not?
See, the important point, and the reason why I made this addition, is for the fact that I'm trying to standardize how jQuery works and the order of arguments for a method. The idiom that I'm molding is: .method( Hash, arg1, ..., argN, ContextFunction ) If a method takes a hash, you'll know that it's the first thing in there. If it takes a context function - it'll always be last. With that in mind, adding on context functions to virtually all methods just makes sense (we were nearly there to begin with). This way, a user can call .load(), .submit(), .parent(), .find(), etc. etc. and know that the last argument can be an optional function that will be executed within the set's context. So, with .filter(foo,function) I'm taking the opportunity to remove the need for: .filter(foo).each(function(){ }).end() Which is good because it's very common, and way too verbose. It's also the same reason why I added the context function to $(...), to remove that common .each() need. When people write the above code, they're effectively building a non-destructive area in which they can work. And it makes sense that way. A lot of what you're doing can depend on how you write your code too, and how you indent it, for example: $(div.test) .find(ul, function(){ $(this).hide() if ( $(#newList:hidden).length ) $(#newList).show('fast'); }) .find(form) .submit(function(){ return false; }) .end(); I'm not confused by the above, although, I am steeped in the code pretty good, so who knows. Comments are definitely appreciated. --John On 10/3/06, Christof Donat [EMAIL PROTECTED] wrote: Hi, I don't know, I've been using .filter( foo, Function ) and .find( foo, Function ) for a while now and I find them to be immensely useful - especially considering that they're non-destructive. Well, if it was destructive it would be more consistent. I don't think that it would be a problem, because you always have end(): $('.hideme').hide().filter('.showme').show().end().addclass('IamCrazy'); is currently equivalent to $('.hideme').hide().filter('.showme', function() { $(this).show(); }).addclass('IamCrazy'); It feels a bit odd to me. I'd expect this to be equal to the first line: $('.hideme').hide().filter('.showme', function() { $(this).show(); }).end().addclass('IamCrazy'); The Problem arises when chaining a lot of filter(), find(), etc. functions. Then your way is IMO less readable. How about shortcut-functions for e.g. filter().end(): $.fn.filterend = function(s,c) { return this.filter(s,c).end(); } $('.hideme').hide().filterend('.showme', function() { $(this).show(); }).addclass('IamCrazy'); I think that would be less confusing. Just my 2 cents. Christof ___ 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/
Re: [jQuery] Single Value Attributes
John Resig schrieb: Hey everyone - I stumbled across a point of optimization today, all of the following attributes (and probably more - let me know) can only have a single value. checked=checked multiple=multiple disabled=disabled readonly=readonly disabled=disabled selected=selected I'd like to add in methods like: .checked( true | false ) Which does this in the background (but for each attribute): $.fn.checked = function(b) { if ( b ) this.attr( checked, checked ); else this.removeAttr( checked ); }; What do you think? John, these are great additions, but please be advised that in some browsers this.attr('checked', 'checked') won't work as expected. I suggest that way (unless the fix is already done in attr which I don't quite remember right now): if ( b ) this.checked = true; else this.checked = false; I think if you want to completely remove the attribute you can use removeAttr but that has to be distinguished from setting the value to false. -- Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Single Value Attributes
Or even more simply: $.fn.checked = function(b) { return b == undefined || b ? this.attr('checked', b) : this.removeAttr('checked'); }; This would handle the return statements nicely, along with non-boolean values (in case someone still wants to pass in the word checked, for example). --John $.fn.checked = function(b) { if( typeof b == 'boolean') { if(b) { this.attr('checked, 'checked'); } else { this.removeAttr('checked'); } else { return this.attr('checked'); } } Could then be categorized within DOM/Attributes, as it aligns nicely with the rest of the set/get methods. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] jQuery 1.0.2 RC1
Sam Collett schrieb: I always thought point releases were just for bug fixes? i.e. if you were adding something it would be 1.1, not 1.0.2 Ye. As the discussion about if/else continues (and John just revealed what all these additional functions passed around are good for), I will remove that for the 1.0.2 release. Out of curiosity, do you have access to change the XML file generated for the docs? It would be helpful (for generating other documentation formats from it) to include the version and revision: docs version=1.0.2 revision=377 I'll have a look at that. -- Jörn ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Single Value Attributes
John, these are great additions, but please be advised that in some browsers this.attr('checked', 'checked') won't work as expected. Do you know which browsers those are offhand? It'll help me to test the methods, when I make them --John ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Fast form serializer function for review
Hi, I've introduced the optimizations proposed by Matt in the serialize version I've already posted (var t = this.type). http://zone.spip.org/trac/spip-zone/browser/_plugins_/_dev_/-jQuery/form.js Renato ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Single Value Attributes
John Resig schrieb: Or even more simply: $.fn.checked = function(b) { return b == undefined || b ? this.attr('checked', b) : this.removeAttr('checked'); }; Ugh. Calling this.attr('checked', b) in the case of b == undefined just returns the attribute, right? Creepy. I like it. -- Jörn ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] For Brandon Aaron
It's not all as black and white as that article suggests. Whilst the user should be setting to null (or their JS framework library), it is ultimately the responsibility of the browser to prevent memory leaks from occuring. Some may point to Dojo and laugh at the memory leakage in their mail client, and they'd be right to. It is really quite bad that the library has so many loose ends, but again, Firefox should ultimately fix these issues. IE does this, and does it well, taking the necessity to explicity nullify out of the heads of developers. Why the Mozilla Foundation has waited so long to plug these particular leaks is unknown to me, but while these problems exists, the browser is still open to some big risks from JavaScript. By the way, if anyone (who does software dev) has actually looked at Firefox's JS code, they'll laugh. It's a real mess. Also, why is this thread specifically for Brandon Aaron? I mean, this is a mailing list, and you can email Brandon directly. If it's for everyone else, then wouldn't 'Firefox still has multiple memory leaks, looky looky' be a better title. Rey Bango-2 wrote: Hey Brandon, Looks like you hit it right on the head with your new event unloader: http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript-memory-leaks/ Check out point #2. Rey... ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- View this message in context: http://www.nabble.com/For-Brandon-Aaron-tf2372925.html#a6617116 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Chainable if/else - hot or not?
Hi, [...] .method( Hash, arg1, ..., argN, ContextFunction ) [...] That all was not my point. My point was that it is irritating that the same function may be destructive or not just by providing the context-function. I'd vote for either never be destructive, or always. Since for functions like filter() it is difficult to go the never destructive-way, I'd like it to be always destructive and have an alternative version which is never destructive. So, with .filter(foo,function) I'm taking the opportunity to remove the need for: .filter(foo).each(function(){ }).end() That is exactly what the suggestet the filterend()-function is for. That way filter() ist always destructive and filterend() never. In both cases with or without a context function. $('div').filter('.test') // return value only contains divs with class 'test' $('div').filter('.test, // return value only contains divs with class 'test' function() { ... }); $('div').filterend('.test') // return value contains all divs (useless) $('div').filterend('.test, // return value contains all divs function() { ... }); The last to calls have the same effect as $('div').filter('.test').end() $('div').filter('.test').each( function() { ... }).end(); In all cases the context function is evaluated for each div with the class 'test'. The difference between filter() and filterend() is just the return value. Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] Couple of bugs to squish
Im having trouble with a couple of bugs that seem to be rearing there head on my site redesign. Im having trouble with thickbox crashing IE6 on the following page: http://www.potn.co.uk/~product_info.php?products_id=1011136 http://www.potn.co.uk/~product_info.php?products_id=1011136 On the same page im having trouble with IE6 and IE7 using tabs plugin combined with round corners plugin to make some prettier tabs. In both cases the plugins work like a dream on FF and Opera Ive tried tweaking DTD between strict and transitional and get a different problem on each. Ive left it on transitional on http://www.potn.co.uk/~index.php this page . Turning off rounded plugin stops the problem with wierd looking boxes, but i do love those round corners. Any help would be great. Simon -- View this message in context: http://www.nabble.com/Couple-of-bugs-to-squish-tf2375213.html#a6617285 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] How should :nth-of-type work?
Just canvassing opinions on the :nth-of-type() selector that is in now being tested in the http://www.softwareunity.com/sandbox/JQueryMoreSelectors/ Selectors Plugin (plus other ...-of-type selectors). At face value it would http://www.nabble.com/nth-of-type-not-working-in-some-cases-tf2356344.html#a6571942 appear to be the same as :eq() but I think there's more to it... In a JQuery set containing 3 DIVs and 3 SPANs (#div0, #div1, #div2, #span0, #span1 #span2), I would expect :eq(1) to return only div1, but :nth-of-type(1) to return div1 and span1. Does this seem correct to you? Taking it a step further, if the set also contains another 3 DIVs (#divX, #divY, and #divZ) that are not siblings of div0,1,2 (ie they have different parents) then my current implementation of :nth-of-type(1) will return div1, span1 and divY. I think I've done it wrong. Should it still return only div1 and span1? I think I've done :nth-sibling-of-type() by mistake! Thanks for you help, George -- View this message in context: http://www.nabble.com/How-should-%3Anth-of-type-work--tf2375279.html#a6617459 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] How should :nth-of-type work?
George Adamson schrieb: Just canvassing opinions on the :nth-of-type() selector that is in now being tested in the http://www.softwareunity.com/sandbox/JQueryMoreSelectors/ Selectors Plugin (plus other ...-of-type selectors). Do you have an example at hand where this selector is actaully useful? -- Jörn ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Chainable if/else - hot or not?
I thought, I'd add on my personal thoughts on this subject. Personally, I find the anonymous function version of filter et. al. to be quite intuitive. You can either modify the stack temporarily and continue the chain until you .end() this modified stack and return to the original, or you can simply apply the methods you want to the argument you provided leaving the original stack intact without needing to .end() the modified stack seeing as it wasn't modified. Please please keep this syntax as it's too elegant to not keep around. -blair Christof Donat wrote: Hi, [...] .method( Hash, arg1, ..., argN, ContextFunction ) [...] That all was not my point. My point was that it is irritating that the same function may be destructive or not just by providing the context-function. I'd vote for either never be destructive, or always. Since for functions like filter() it is difficult to go the never destructive-way, I'd like it to be always destructive and have an alternative version which is never destructive. So, with .filter(foo,function) I'm taking the opportunity to remove the need for: .filter(foo).each(function(){ }).end() That is exactly what the suggestet the filterend()-function is for. That way filter() ist always destructive and filterend() never. In both cases with or without a context function. $('div').filter('.test') // return value only contains divs with class 'test' $('div').filter('.test, // return value only contains divs with class 'test' function() { ... }); $('div').filterend('.test') // return value contains all divs (useless) $('div').filterend('.test, // return value contains all divs function() { ... }); The last to calls have the same effect as $('div').filter('.test').end() $('div').filter('.test').each( function() { ... }).end(); In all cases the context function is evaluated for each div with the class 'test'. The difference between filter() and filterend() is just the return value. Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Fast form serializer function for review
Very nice, Matt. This serialize method is way faster if the select element is not a multiple select which I assume is how you benchmarked it. When the select is a multiple-select then I see basically the same performance with the for-loop impl posted on the other thread. I did a quick test and got the following results: muliple-select element w/500 options: new 'each' impl (ave of 10 tests): 113ms for-loop impl (ave of 10 tests): 104ms single-select element w/500 options: new 'each' impl (ave of 10 tests): 7ms for-loop impl (ave of 10 tests): 103ms So I think this new serialize method is pretty damn good! Is there *anyone* out there that cares about the semantic ordering of the posted values? Personally, I do not, and I definitely would like to have only a single serialize method. Maybe the semantic version could be left as a separate plugin for anyone that needs that capability. I vote for updating the form plugin with this new version. Mike On 10/3/06, Matt Grimm [EMAIL PROTECTED] wrote: Hello, I've put together a fast form serializer function that I'm hoping can get some review from the list for completeness, bugs, a better name, etc. A previous thread revealed quite a performance issue with the form plugin's existing serialize function when operating on a form with a large number of elements. My plugin sacrifices semantic order for wicked speed. I have a test form with a select menu containing 500 options -- with the current serializer, it takes around 5 full seconds to do the job, and with mine, it takes about 50 ms. Any feedback would be much appreciated, including whether you think this should be included with the form plugin distribution. Since this isn't a plugin, I'm just going to include the source in this message -- please let me know if there's a better (i.e., more polite) way to do this. Thanks! m. --- $.fn.fastSerialize = function() { var a = []; var f = ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON']; $(f.join(','), this).each(function() { var n = this.name || this.id; var t = this.type; if (!n || this.disabled || t == 'reset' || (t == 'checkbox' || t == 'radio') !this.checked || (t == 'submit' || t == 'image' || t == 'button') this.form.clicked != this || this.tagName == 'SELECT' this.selectedIndex == -1) return; if (t == 'image' this.form.clicked_x) return a.push( {name: n+'_x', value: this.form.clicked_x}, {name: n+'_y', value: this.form.clicked_y} ); if (t == 'select-multiple') { $('option', this).each( function() { if (this.selected) a.push({name: n, value: this.value || $(this).text()}); }); return; } a.push({name: n, value: this.value}); }); return a; }; ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Chainable if/else - hot or not?
I like this idea. I think that it gives everyone what they want, and none of the methods are going to be as confusing to a newcomer that way. My one complaint is that I don't like filterend as a method name. It sounds... clunky. I'm sure that one of us can do better. :) - Brian Hi, I don't know, I've been using .filter( foo, Function ) and .find( foo, Function ) for a while now and I find them to be immensely useful - especially considering that they're non-destructive. Well, if it was destructive it would be more consistent. I don't think that it would be a problem, because you always have end(): $('.hideme').hide().filter('.showme').show().end().addclass('IamCrazy'); is currently equivalent to $('.hideme').hide().filter('.showme', function() { $(this).show(); }).addclass('IamCrazy'); It feels a bit odd to me. I'd expect this to be equal to the first line: $('.hideme').hide().filter('.showme', function() { $(this).show(); }).end().addclass('IamCrazy'); The Problem arises when chaining a lot of filter(), find(), etc. functions. Then your way is IMO less readable. How about shortcut-functions for e.g. filter().end(): $.fn.filterend = function(s,c) { return this.filter(s,c).end(); } $('.hideme').hide().filterend('.showme', function() { $(this).show(); }).addclass('IamCrazy'); I think that would be less confusing. Just my 2 cents. Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Fast form serializer function for review
Mat, This code: if (t == 'select-multiple') { $('option', this).each( function() { if (this.selected) a.push({name: n, value: this.value || $(this).text()}); }); return; } Can be changed to this, if i am right ;) if (t == 'select-multiple') { $('[EMAIL PROTECTED]selected]', this).each( function() { a.push({name: n, value: this.value || $(this).text()}); }); return; } Other then that, Great code! -- Gilles ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] To what extent is XPath actually supported?
I have this simple markup: componentDom.innerHTML = form action=""> h1 name=formTitle/h1 p name=formInstructions/p div name=top /div div name=formContent divname=columndiv /div/div /div div name=bottom input type=submit name=defaultButton value=Submit/ /div/form I'm executing this xpath calls with the following results: $('form/[EMAIL PROTECTED]', componentDom).length = 3 $('form/[EMAIL PROTECTED]', componentDom)[0].innerHTML = $('form/[EMAIL PROTECTED]', componentDom)[1].innerHTML= DIV name=\column\DIV/DIV/DIV $('form/[EMAIL PROTECTED]', componentDom)[2].innerHTMLINPUT type=submit value=Submit name=defaultButton $('form/[EMAIL PROTECTED]/input', componentDom)Object requiredError $('//div', componentDom)'undefined' is null or not an objectError $('form//div', componentDom).length= 6 $('form//div/input', componentDom).length= Object requiredError I don't understand why it's failing! I'm just asking for the input which it's obviously there, under the last DIV. Like this, I've come across many really simple XPath queries that just don't work. Am I doing something wrong? Is it XPath actually supported? Moreover: Queries like: $('form//div/input', componentDom); break in the siblingfunction(elem, pos, not) since elem is null. Probably this is related to the bug where children() breaks at that same point when there are no children. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Chainable if/else - hot or not?
Elegant? Perhaps. Breaks the Principle of Least Surprise? Absolutely, unfortunately. I'm with Chris. One method that's always destructive, and another method that's always not. - Brian I thought, I'd add on my personal thoughts on this subject. Personally, I find the anonymous function version of filter et. al. to be quite intuitive. You can either modify the stack temporarily and continue the chain until you .end() this modified stack and return to the original, or you can simply apply the methods you want to the argument you provided leaving the original stack intact without needing to .end() the modified stack seeing as it wasn't modified. Please please keep this syntax as it's too elegant to not keep around. -blair Christof Donat wrote: Hi, [...] .method( Hash, arg1, ..., argN, ContextFunction ) [...] That all was not my point. My point was that it is irritating that the same function may be destructive or not just by providing the context-function. I'd vote for either never be destructive, or always. Since for functions like filter() it is difficult to go the never destructive-way, I'd like it to be always destructive and have an alternative version which is never destructive. So, with .filter(foo,function) I'm taking the opportunity to remove the need for: .filter(foo).each(function(){ }).end() That is exactly what the suggestet the filterend()-function is for. That way filter() ist always destructive and filterend() never. In both cases with or without a context function. $('div').filter('.test') // return value only contains divs with class 'test' $('div').filter('.test, // return value only contains divs with class 'test' function() { ... }); $('div').filterend('.test') // return value contains all divs (useless) $('div').filterend('.test, // return value contains all divs function() { ... }); The last to calls have the same effect as $('div').filter('.test').end() $('div').filter('.test').each( function() { ... }).end(); In all cases the context function is evaluated for each div with the class 'test'. The difference between filter() and filterend() is just the return value. Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] To what extent is XPath actually supported?
I have this simple markup: componentDom.innerHTML = form action=""> h1 name=formTitle/h1 p name=formInstructions/p div name=top /div div name=formContent divname=columndiv /div/div /div div name=bottom input type=submit name=defaultButton value=Submit/ /div/form I'm executing this xpath calls with the following results: $('form/[EMAIL PROTECTED]', componentDom).length = 3 $('form/[EMAIL PROTECTED]', componentDom)[0].innerHTML = $('form/[EMAIL PROTECTED]', componentDom)[1].innerHTML= DIV name=\column\DIV/DIV/DIV $('form/[EMAIL PROTECTED]', componentDom)[2].innerHTMLINPUT type=submit value=Submit name=defaultButton $('form/[EMAIL PROTECTED]/input', componentDom)Object requiredError $('//div', componentDom)'undefined' is null or not an objectError $('form//div', componentDom).length= 6 $('form//div/input', componentDom).length= Object requiredError I don't understand why it's failing! I'm just asking for the input which it's obviously there, under the last DIV. Like this, I've come across many really simple XPath queries that just don't work. Am I doing something wrong? Is it XPath actually supported? Moreover: Queries like: $('form//div/input', componentDom); break in the siblingfunction(elem, pos, not) since elem is null. Probably this is related to the bug where children() breaks at that same point when there are no children. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Fast form serializer function for review
I'd say that .serialize() should take a boolean argument, retainOrder, which will retain semantic order if true, and not if false/null/not entered. That would be perfect. The documentation should then make clear that the retainOrder option will be slower for large forms. - Brian I wonder if we could reduce the overall code by merging both seriliaze methods. -- Jörn ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Chainable if/else - hot or not?
FYI, you can already call an extra Function argument on any destructive operation, for example: .find( foo, ifCallback ) .filter( foo, ifCallback ) .not( foo, ifCallback ) I didn't document this yet, since I didn't think anyone was going to care to use it, except for me. Heh. I use it in a few places already because of some issues with pushStack holding references to nodes that have been removed from the document: http://jquery.com/dev/bugs/bug/30/ It would still be nice to have chained operations though. Why not use the pushStack stack as an operand? For example, if you want the else part, just have a .invert() method that takes the current node set and selects all the nodes on the stack that aren't already in that set. $() .filter() .stuff().to().filtered().nodes() .invert() .stuff().to().remaining().nodes() .end() Yes, .invert() is destructive to the current node set, but if you need the original filtered nodes back you just invert them again. One other thing I've wanted a couple of times is a method that would add nodes only if the current node set was empty. Kind of like the || operator in Javascript. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Fast form serializer function for review
Mike Alsup wrote: Or better yet: $('option:selected')... Hey Mike, is that supported by jQuery? If i am right, only a plugin adds that method of selecting.. -- Gilles ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Fast form serializer function for review
That would actually have to ripple through all three methods in the form plugin, not just the serialize method. On 10/3/06, Brian [EMAIL PROTECTED] wrote: I'd say that .serialize() should take a boolean argument, retainOrder, which will retain semantic order if true, and not if false/null/not entered. That would be perfect. The documentation should then make clear that the retainOrder option will be slower for large forms. - Brian I wonder if we could reduce the overall code by merging both seriliaze methods. -- Jörn ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] input and textarea field resizing
I ran across a plugin that would automatically expand an input or text area field while typing... but I can't seem to find it now. Anyone know what I'm talking about or where its at? Thanks. -- View this message in context: http://www.nabble.com/input-and-textarea-field-resizing-tf2376275.html#a6620356 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] Bug in fx?
When using idrag.js and a created drag with fx:100 for instance, the current jQuery SVN bails on line 3938 with the error: *z.e.curAnim has no properties* This is the line: z.el.curAnim[ prop ] = true; The lines: if (z.el.curAnim) z.el.curAnim[ prop ] = true; work, but i don't know if that is the correct way to do so. -- Gilles ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] input and textarea field resizing
On Oct 3, 2006, at 9:39 AM, Brian Litzinger wrote: I ran across a plugin that would automatically expand an input or text area field while typing... but I can't seem to find it now. Anyone know what I'm talking about or where its at? Thanks. Hi Brian, It's part of the Interface plugin. http://interface.eyecon.ro/ It's called Autoexpand. Here is the demo page: http://interface.eyecon.ro/demos/expander.html Cheers, Karl ___ Karl Swedberg www.englishrules.com www.learningjquery.com ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] input and textarea field resizing
Brian Litzinger schreef: I ran across a plugin that would automatically expand an input or text area field while typing... but I can't seem to find it now. Anyone know what I'm talking about or where its at? Thanks. I think you are talking about this http://interface.eyecon.ro/demos/expander.html and the dowload can be found at http://interface.eyecon.ro/download -- David Duymelinck [EMAIL PROTECTED] ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] Newbie question about document ready statement
Please forgive what might seem a stupidly basic question but I'm new to jQuery and the tutorials/API doc have not made the answer clear to me: Should you use a separate $(document).ready(function(){ // Your code here }); for each function you write, or do you just have one wrapping ready statement and put all your functions inside it? Thanks, Paul Caton. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Newbie question about document ready statement
You can put all your functions inside one $(document).ready( ); , or use the shorthand $(function(){}); , but then you have to be aware that ajax generated html will not fire because the page hasn't reloaded. For ajax generated code you best put your functions outside the $(document).ready( ); and call then inside. Caton, Paul schreef: Please forgive what might seem a stupidly basic question but I'm new to jQuery and the tutorials/API doc have not made the answer clear to me: Should you use a separate $(document).ready(function(){ // Your code here }); for each function you write, or do you just have one wrapping ready statement and put all your functions inside it? Thanks, Paul Caton. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- David Duymelinck [EMAIL PROTECTED] ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Newbie question about document ready statement
Paul, Either is fine; JQuery will happily execute one or more ready statements. If you have multiples, they will be executed in the order in which they are encountered in the code. I personally use a modular approach, since different pages may utilize only a portion of the available functions. My attitude is, why load what isn't used? Of course, YMMV (your mileage may vary). Welcome to JQuery! Kevin -- Original message -- From: Caton, Paul [EMAIL PROTECTED] Please forgive what might seem a stupidly basic question but I'm new to jQuery and the tutorials/API doc have not made the answer clear to me: Should you use a separate $(document).ready(function(){ // Your code here }); for each function you write, or do you just have one wrapping ready statement and put all your functions inside it? Thanks, Paul Caton. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] input and textarea field resizing
Ugh, and I just went to the Interface site and didn't see it. Thanks. -- View this message in context: http://www.nabble.com/input-and-textarea-field-resizing-tf2376275.html#a6620900 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] For Brandon Aaron
Hi Dan, It was titled as such because Brandon recently posted code to address a memory leak he found in JQuery's handling of events. I'll try to get a better title in place next time. Rey... Also, why is this thread specifically for Brandon Aaron? I mean, this is a mailing list, and you can email Brandon directly. If it's for everyone else, then wouldn't 'Firefox still has multiple memory leaks, looky looky' be a better title. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Newbie question about document ready statement
[EMAIL PROTECTED] schreef: I personally use a modular approach, since different pages may utilize only a portion of the available functions. My attitude is, why load what isn't used? Of course, YMMV (your mileage may vary). The approach I take for loading functions is taking a page element id that is unique for the website and check if it's there with the size function if($('#someid').size() = 1){ //functions for that page } i don't know if it's the best way but it worked for me so far. -- David Duymelinck [EMAIL PROTECTED] ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Chainable if/else - hot or not?
Brian wrote: Elegant? Perhaps. Breaks the Principle of Least Surprise? Absolutely, unfortunately. I don't find it to be surprising at all. If you run filter without specifying what you want to do with the subset it creates via a secondary lambda argument, the stack is modified to allow you to act on that subset while retaining the original stack allowing you to return to it via an .end() call. If you specify a callback, it is smart enough to realize you want to use that callback on the subset and that's all. So it doesn't modify the set and the chain continues unmodified. It makes sense to me but, as with anything, that means nothing for anyone else. -blair ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Chainable if/else - hot or not?
$() .filter() .stuff().to().filtered().nodes() .invert() .stuff().to().remaining().nodes() .end() invert ... that is so much better than $else or otherwise. I like this for an all jQuery method solution. -- Brandon Aaron ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] jQuery + Atlas (ASP.NET AJAX) or $ conflict
Before I dirty my hands digging around in 'Atlas' http://atlas.asp.net/ I thought it worthwhile asking the question here: Has anyone successfully combined jQuery with this particular Microsoft JavaScript library? jQuery is failing after some 'Atlas' code is introduced into the same page. I have not looked into it closely myself. I am told the problem is something to do with '$' being used by 'Atlas'. I'd love to talk our developers out of using Atlas altogether, but as a designer I lack the appropriate credentials in this department. Apparently Atlas is great because we don't need to write any JavaScript to use it... ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] How should :nth-of-type work?
Good point J?rn, thank you. (I've not found a good use for :nth-of-type() myself, but someome will!) More interesting as it turns out, is the :nth-sibling-of-type() selector that I created accidentally... It turns out to be a simple way of returning TD elements in the same column of a table. Here are two examples on a form and a table: http://www.softwareunity.com/sandbox/JQueryMoreSelectors/nth-of-type/ Original test page is here: http://www.softwareunity.com/sandbox/JQueryMoreSelectors/ George J?rn Zaefferer wrote: Do you have an example at hand where this selector is actaully useful? -- J?rn -- View this message in context: http://www.nabble.com/How-should-%3Anth-of-type-work--tf2375279.html#a6621407 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] jQuery + Atlas (ASP.NET AJAX) or $ conflict
You might look at the PrototypeAndJQuery page on the wiki: http://jquery.com/docs/PrototypeAndJQuery/ The first section probably isn't applicable, but the second portion looks like a workaround that might work with the Atlas client side stuff. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Oliver Boermans Sent: Tuesday, October 03, 2006 9:29 AM To: jQuery Discussion. Subject: [jQuery] jQuery + Atlas (ASP.NET AJAX) or $ conflict Before I dirty my hands digging around in 'Atlas' http://atlas.asp.net/ I thought it worthwhile asking the question here: Has anyone successfully combined jQuery with this particular Microsoft JavaScript library? jQuery is failing after some 'Atlas' code is introduced into the same page. I have not looked into it closely myself. I am told the problem is something to do with '$' being used by 'Atlas'. I'd love to talk our developers out of using Atlas altogether, but as a designer I lack the appropriate credentials in this department. Apparently Atlas is great because we don't need to write any JavaScript to use it... ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Chainable if/else - hot or not?
Brandon Aaron schrieb: $() .filter() .stuff().to().filtered().nodes() .invert() .stuff().to().remaining().nodes() .end() invert ... that is so much better than $else or otherwise. I like this for an all jQuery method solution. Ok, apart from a different name, that is the same $else method. But what happens if you do something like this: $() .filter() .filter() .doStuff() .invert() .doOtherStuff() .invert() doMoreStuff(); This is very difficult to implement, because the second invert has to revert (end()) both the filter and the invert operation. Other problems arise when you want to invert operations done via not() or find() etc. -- Jörn ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Fast form serializer function for review
Webunity | Gilles van den Hoven schrieb: Mike Alsup wrote: Or better yet: $('option:selected')... Hey Mike, is that supported by jQuery? If i am right, only a plugin adds that method of selecting.. I dunno since when, but it is in the core. Maybe post-1.0. -- Jörn ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Fast form serializer function for review
I don't think that's proper behavior, though. *Both* values of foo should be posted if both are present. So, you'd either get foo=offValue, or foo=offValue,onValue. Either way, your backend code shouldn't break if the submitted fields are in the wrong order. - Brian On 10/3/06, Mike Alsup [EMAIL PROTECTED] wrote: So I think this new serialize method is pretty damn good! Is there *anyone* out there that cares about the semantic ordering of the posted values? Personally, I do not, and I definitely would like to have only a single serialize method. Maybe the semantic version could be left as a separate plugin for anyone that needs that capability. I vote for updating the form plugin with this new version. Yes, I care. Case: An unchecked checkbox doesn't post. However, you usually want to work with an on/off value. I use this construct (stolen from Rails I think): input type=hidden name=foo value=offValue input type=checkbox name=foo value=onValue This way, when the checkbox is not checked, offValue is posted for foo. When checked, onValue is posted. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Chainable if/else - hot or not?
Hi, Ok, apart from a different name, that is the same $else method. But what happens if you do something like this: $() .filter() .filter() .doStuff() .invert() .doOtherStuff() .invert() doMoreStuff(); That is very simple: the second invert() inverts the set that the first invert() has returned. To do what you might have thought about you need to use end(): $() .filter() .filter() .doStuff() .invert() .doOtherStuff() .end() .invert() doMoreStuff(); If course the invert()-function can not guess the indentation of your code. Actually I think, that else() or otherwise() may be better names for it. For me invert() sounds like a fx-function that swaps the foreground- and the background-color. Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] String Parsing
this might not be jquery related, but i noticed there are a lot of savvy javascript programmers in this mailing list. i want to grab just the filename and extension from the following string: str1=F:\\Test1\\Test2\\Test3\\test.txt; i want to grab test.txt i use this code: file1=(str1.split(\\))[(str1.split(\\)).length-1]; i was wondering if there is a better way to grab that part of the string Thx for any help -- View this message in context: http://www.nabble.com/String-Parsing-tf2376878.html#a6622443 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] String Parsing
I'm no great js programmer, but that looks about right. !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Tombo Sent: Tuesday, October 03, 2006 10:22 AM To: discuss@jquery.com Subject: [jQuery] String Parsing this might not be jquery related, but i noticed there are a lot of savvy javascript programmers in this mailing list. i want to grab just the filename and extension from the following string: str1=F:\\Test1\\Test2\\Test3\\test.txt; i want to grab test.txt i use this code: file1=(str1.split(\\))[(str1.split(\\)).length-1]; i was wondering if there is a better way to grab that part of the string Thx for any help -- View this message in context: http://www.nabble.com/String-Parsing-tf2376878.html#a6622443 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Serializing XML
Hi, I like optimized code as much as the next guy... but brevity and readability is KEY. the milliseconds that you can save using one reasonable technique vs. another are not comparable to the seconds it takes for an http request. Is this about my suggestion to use for() instead of each()? If not, my code is not noticably longer than Marks. I also don't think that it is less readable. If you are just talking about the for()-each() stuff. Both have their advantages and their disadvantages. If it is the inner loop of a function you expect to call often, you may whant to pay the price of less readability and brevity for the performance of for(). I never liked using XMLSerializer because [...] It can be quite usefull with XMLHttpRequests when your protocol is XML-based. But that was not the question here, was it? Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] String Parsing
try using a regex and matching ([^\]+$) I'm not up on my \ escaping for javascript, so you may need a different number of \'s in there to make it work Tombo wrote: this might not be jquery related, but i noticed there are a lot of savvy javascript programmers in this mailing list. i want to grab just the filename and extension from the following string: str1=F:\\Test1\\Test2\\Test3\\test.txt; i want to grab test.txt i use this code: file1=(str1.split(\\))[(str1.split(\\)).length-1]; i was wondering if there is a better way to grab that part of the string Thx for any help ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] String Parsing
Tombo schrieb: i want to grab just the filename and extension from the following string: str1=F:\\Test1\\Test2\\Test3\\test.txt; i want to grab test.txt i use this code: file1=(str1.split(\\))[(str1.split(\\)).length-1]; i was wondering if there is a better way to grab that part of the string How about this: file1 = str1.substring( str1.lastIndexOf(\\) ); -- Jörn ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] String Parsing
To avoid running split twice, you could do it this way (removes IE5 from compatibility however): var file1 = str1.split(\\).pop(); -blair Tombo wrote: this might not be jquery related, but i noticed there are a lot of savvy javascript programmers in this mailing list. i want to grab just the filename and extension from the following string: str1=F:\\Test1\\Test2\\Test3\\test.txt; i want to grab test.txt i use this code: file1=(str1.split(\\))[(str1.split(\\)).length-1]; i was wondering if there is a better way to grab that part of the string Thx for any help ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] String Parsing
ahhh that works nicely although i just had to add one file1=str1.substring(str1.lastIndexOf(\\)+1); J?rn Zaefferer wrote: Tombo schrieb: i want to grab just the filename and extension from the following string: str1=F:\\Test1\\Test2\\Test3\\test.txt; i want to grab test.txt i use this code: file1=(str1.split(\\))[(str1.split(\\)).length-1]; i was wondering if there is a better way to grab that part of the string How about this: file1 = str1.substring( str1.lastIndexOf(\\) ); -- J?rn ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- View this message in context: http://www.nabble.com/String-Parsing-tf2376878.html#a6622835 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] Evaluating script elements
Hi, I believe there is a flaw in the way scripts are evaluated in the 'load' function. This piece of code is my concern: // Execute all the scripts inside of the newly-injected HTML $(script, self).each(function(){ if ( this.src ) $.getScript( this.src ); else eval.call( window, this.text || this.textContent || this.innerHTML || ); }); It doesn't load scripts (with src attribute) in expected way that a browser would. Take the following snippet of html: script src=fancy-plugin.js/script script $('#foo').FancyPlugin(); /script Loaded in a normal html page in the normal way in a browser, fancy-plugin.js would be loaded and ready, before the second script is executed. If loaded via 'load', then 'fancy-plugin.js' is loaded asyncronously, and may not be evaluated before the second literal script is. You see the problem? The solution is to wait for each script to load before executing the next. Here's my solution as a plugin: (I was thinking it should probably be added to the core as a reusable function, and called from within 'load', replacing the snippet above) $.fn.eval = function(callback) { var self = this; var exec = function(scripts) { console.log(scripts); for (var i=0; i scripts.length; i++) { if (scripts[i].src) { $.getScript(scripts[i].src, function() { if (i+1 scripts.length) { // Continue executing remaining of scripts exec(scripts.gt(i)); } else if (typeof callback == 'function') { // This was last script, so call the callback fn callback.call(self); } }); // Remaining scripts will be eval'd after this script is loaded return; } else { // Evaluate the content as the script eval.call(window, scripts[i].text || scripts[i].textContent || scripts[i].innerHTML || ); } } if (typeof callback == 'function') callback.call(self); } exec($(this).filter('script')); return this; }; BTW: this was tested with jQuery rev 384. Cheers - Mark Gibson ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] String Parsing
yes. this was the elegance i was looking for. thx Blair Mitchelmore-2 wrote: To avoid running split twice, you could do it this way (removes IE5 from compatibility however): var file1 = str1.split(\\).pop(); -blair Tombo wrote: this might not be jquery related, but i noticed there are a lot of savvy javascript programmers in this mailing list. i want to grab just the filename and extension from the following string: str1=F:\\Test1\\Test2\\Test3\\test.txt; i want to grab test.txt i use this code: file1=(str1.split(\\))[(str1.split(\\)).length-1]; i was wondering if there is a better way to grab that part of the string Thx for any help ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- View this message in context: http://www.nabble.com/String-Parsing-tf2376878.html#a6622882 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] String Parsing
Hi, i want to grab just the filename and extension from the following string: str1=F:\\Test1\\Test2\\Test3\\test.txt; i want to grab test.txt i use this code: file1=(str1.split(\\))[(str1.split(\\)).length-1]; i was wondering if there is a better way to grab that part of the string Yes, of course: var tmp = str1.split(\\); file1 = tmp[tmp.length-1]; That way the JS-interpreter doesn't need to split the string twice. I think that this is the fastest aproach. Another aproach could be: file1 = str1; var tmp; while( (tmp = file1.indexOf(\\)) = 0 ) file1 = file1.substr(tmp+1); But I think, that is slower. The advantage is that it is easy to understand that you ar working on the string. Yet another aproach: file1 = str1.match(/[^\\]*$/); I guess this can compete in performance with the split()-method - shold be just a bit slower since the evaluation of a regular expression is more complex than a simple split. It is the shortest variant, but not the most readable. If you ask me I would either recomend the split()-method or the regular-expression-method. Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] Started on window class for jQuery
Hi Guys, I have decided to share my subModal class. I started this lightbox of me right after i saw the first lightbox for prototype (so i have been coding on this one for almost 1 year now). It is going to have a lot of features and will off-course be shared with you guys. At the current state it basicly is thesame as all other ones out there, but that is going to change. I'll start coding on it tomorrow and hope to show something in a couple (3-4) of weeks. -- Gilles p.s. the window class will be using code from Stefan Petre's interface pack, especially for the drag code and effects. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] String Parsing
nice. i like that regular expression example. but i agree that the split method is probably quicker. thanks Christof Donat wrote: Hi, i want to grab just the filename and extension from the following string: str1=F:\\Test1\\Test2\\Test3\\test.txt; i want to grab test.txt i use this code: file1=(str1.split(\\))[(str1.split(\\)).length-1]; i was wondering if there is a better way to grab that part of the string Yes, of course: var tmp = str1.split(\\); file1 = tmp[tmp.length-1]; That way the JS-interpreter doesn't need to split the string twice. I think that this is the fastest aproach. Another aproach could be: file1 = str1; var tmp; while( (tmp = file1.indexOf(\\)) = 0 ) file1 = file1.substr(tmp+1); But I think, that is slower. The advantage is that it is easy to understand that you ar working on the string. Yet another aproach: file1 = str1.match(/[^\\]*$/); I guess this can compete in performance with the split()-method - shold be just a bit slower since the evaluation of a regular expression is more complex than a simple split. It is the shortest variant, but not the most readable. If you ask me I would either recomend the split()-method or the regular-expression-method. Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- View this message in context: http://www.nabble.com/String-Parsing-tf2376878.html#a6623119 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Evaluating script elements
2006/10/3, Mark Gibson [EMAIL PROTECTED]: The solution is to wait for each script to load before executing the next. Here's my solution as a plugin: It reminds me of a post I made: http://jquery.com/discuss/2006-June/005496/. It was not specific to scripts loads but could be tweaked to work with. Cheers, Franck. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Evaluating script elements
Looks good, but please don't use eval as the function name. It's a Bad Idea to overload reserved/predefined words, even if namespaced. - Brian $.fn.eval = function(callback) { ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Rev: 259, where is now?
Andrea Ercolino wrote: I don't know how I got Rev: 259, because current latest is 249. I wandered around but I cannot find a link to it in jquery.com. Each time someone of the developers (like me) commit something, the version number is increased. Therefore since your last download, 10 commitments where done, leaving you at 259. The exact size of each commitment is very different. One time it is only 1 small bug, the other time it is a bigger list of bugs. HTH, GIlles ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Evaluating script elements
any ideas? maybe evaluate()? ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Evaluating script elements
Brian wrote: Looks good, but please don't use eval as the function name. It's a Bad Idea to overload reserved/predefined words, even if namespaced. Oops, sorry. I was going to rename it before submitting the suggestion. How about: evalScript() exec() execScript() any ideas? ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] Rev: 259, where is now?
I don't know how I got Rev: 259, because current latest is 249. I wandered around but I cannot find a link to it in jquery.com. 259worksbetter with IE than 249 For example,259 let meaccess tabs in a pre tag, while 249 doesn't ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Rev: 259, where is now?
thanks, but really I meant "where do I get a Rev = 259?" - Original Message From: Webunity | Gilles van den Hoven [EMAIL PROTECTED]To: jQuery Discussion. discuss@jquery.comSent: Tuesday, October 3, 2006 6:06:34 PMSubject: Re: [jQuery] Rev: 259, where is now? Andrea Ercolino wrote: I don't know how I got Rev: 259, because current latest is 249. I wandered around but I cannot find a link to it in jquery.com.Each time someone of the developers (like me) commit something, the version number is increased. Therefore since your last download, 10 commitments where done, leaving you at 259. The exact size of each commitment is very different. One time it is only 1 small bug, the other time it is a bigger list of bugs.HTH, GIlles___jQuery mailing listdiscuss@jquery.comhttp://jquery.com/discuss/___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Fast form serializer function for review
Thanks for catching this Klaus, I've updated the code to normalize tag names. m. On Tue, 2006-10-03 at 11:21 +0200, Klaus Hartl wrote: Klaus Hartl schrieb: Please make it XHTML as XML compatible (hm, why is it always me complaining about that?)...: There's missing a part, I'm sorry, please normalize tag names: var f = ['input', 'textarea', 'select', 'button']; and this.tagName.toLowerCase() == 'select' Thank you, Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Fast form serializer function for review
Good call, I've updated it to use your syntax for f. Added benefit: the selector reads f this. m. On Tue, 2006-10-03 at 00:35 -0700, Michael Geary wrote: Nice. You could simplify this: var f = ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON']; $(f.join(','), this).each(function() { to: var f = 'INPUT,TEXTAREA,SELECT,BUTTON'; $(f, this).each(function() { BTW, what do you mean when you say it isn't a plugin? Looks like one to me. :-) -Mike From: Matt Grimm I've put together a fast form serializer function that I'm hoping can get some review from the list for completeness, bugs, a better name, etc. A previous thread revealed quite a performance issue with the form plugin's existing serialize function when operating on a form with a large number of elements. My plugin sacrifices semantic order for wicked speed. I have a test form with a select menu containing 500 options -- with the current serializer, it takes around 5 full seconds to do the job, and with mine, it takes about 50 ms. Any feedback would be much appreciated, including whether you think this should be included with the form plugin distribution. Since this isn't a plugin, I'm just going to include the source in this message -- please let me know if there's a better (i.e., more polite) way to do this. Thanks! m. --- $.fn.fastSerialize = function() { var a = []; var f = ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON']; $(f.join(','), this).each(function() { var n = this.name || this.id; var t = this.type; if (!n || this.disabled || t == 'reset' || (t == 'checkbox' || t == 'radio') !this.checked || (t == 'submit' || t == 'image' || t == 'button') this.form.clicked != this || this.tagName == 'SELECT' this.selectedIndex == -1) return; if (t == 'image' this.form.clicked_x) return a.push( {name: n+'_x', value: this.form.clicked_x}, {name: n+'_y', value: this.form.clicked_y} ); if (t == 'select-multiple') { $('option', this).each( function() { if (this.selected) a.push({name: n, value: this.value || $(this).text()}); }); return; } a.push({name: n, value: this.value}); }); return a; }; ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Rev: 259, where is now?
I don't know how I got Rev: 259, because current latest is 249. I wandered around but I cannot find a link to it in jquery.com. The last rev is #387, accessible via svn (http://jquery.com/src/) 259 works better with IE than 249 For example, 259 let me access tabs in a pre tag, while 249 doesn't It should be better and better ;-) Franck. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Fast form serializer function for review
The option:selected is the only syntax that has worked for me in the past. The XPath method only gets those options that literally have an attribute of selected in the XHTML. I also agree with you on the matter of excluding this.id as a fallback for n. It's unnecessary and possibly confusing behavior. m. On Tue, 2006-10-03 at 09:14 -0400, Mike Alsup wrote: Or better yet: $('option:selected')... Also, I think I'd get rid of this: var n = this.name || this.id; because the id should not be used for the name. I think that's always been wrong and it would result in a different behavior when javascript is disabled. Mike On 10/3/06, Webunity | Gilles van den Hoven [EMAIL PROTECTED] wrote: Mat, This code: if (t == 'select-multiple') { $('option', this).each( function() { if (this.selected) a.push({name: n, value: this.value || $(this).text()}); }); return; } Can be changed to this, if i am right ;) if (t == 'select-multiple') { $('[EMAIL PROTECTED]selected]', this).each( function() { a.push({name: n, value: this.value || $(this).text()}); }); return; } Other then that, Great code! -- Gilles ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Fast form serializer function for review
Good point, Jörn. Not only would you want to be able to submit an empty string value for an option, but if the value attribute is excluded from the option tag, this.value will return the text between the tags anyway. m. On Tue, 2006-10-03 at 11:17 +0200, Jörn Zaefferer wrote: Matt Grimm schrieb: I've put together a fast form serializer function that I'm hoping can get some review from the list for completeness, bugs, a better name, etc. A previous thread revealed quite a performance issue with the form plugin's existing serialize function when operating on a form with a large number of elements. My plugin sacrifices semantic order for wicked speed. I have a test form with a select menu containing 500 options -- with the current serializer, it takes around 5 full seconds to do the job, and with mine, it takes about 50 ms. Any feedback would be much appreciated, including whether you think this should be included with the form plugin distribution. AFAIK the form plugin pretended to send the form as if it was a normal submit. While I haven't seen a problem with the order yet, I see a problem with this: $('option', this).each( function() { if (this.selected) a.push({name: n, value: this.value || $(this).text()}); }); If the user submits a option value=Please select.../option, I want the empty value to be submitted, not the text. Apart from that, nice work. I wonder if we could reduce the overall code by merging both seriliaze methods. -- Jörn ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Rev: 259, where is now?
Thanks Franck, but I feel a dummy now. Where is the link to download this 387 version? - Original Message From: Franck Marcia [EMAIL PROTECTED]To: jQuery Discussion. discuss@jquery.comSent: Tuesday, October 3, 2006 6:09:43 PMSubject: Re: [jQuery] Rev: 259, where is now? I don't know how I got Rev: 259, because current latest is 249. I wandered around but I cannot find a link to it in jquery.com.The last rev is #387, accessible via svn (http://jquery.com/src/) 259 works better with IE than 249 For example, 259 let me access tabs in a pre tag, while 249 doesn'tIt should be better and better ;-)Franck.___jQuery mailing listdiscuss@jquery.comhttp://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Fast form serializer function for review
OK, I've made several modifications thanks to your suggestions and corrections. This is publishable; should I go ahead and create a new wiki page under Plugins or maybe wait until it's decided whether this will be merged somehow with the existing form plugin? m. --- $.fn.fastSerialize = function() { var a = []; $('input,textarea,select,button', this).each(function() { var n = this.name; var t = this.type; if ( !n || this.disabled || t == 'reset' || (t == 'checkbox' || t == 'radio') !this.checked || (t == 'submit' || t == 'image' || t == 'button') this.form.clicked != this || this.tagName.toLowerCase() == 'select' this.selectedIndex == -1) return; if (t == 'image' this.form.clicked_x) return a.push( {name: n+'_x', value: this.form.clicked_x}, {name: n+'_y', value: this.form.clicked_y} ); if (t == 'select-multiple') { $('option:selected', this).each( function() { a.push({name: n, value: this.value}); }); return; } a.push({name: n, value: this.value}); }); return a; }; On Mon, 2006-10-02 at 21:02 -0800, Matt Grimm wrote: Hello, I've put together a fast form serializer function that I'm hoping can get some review from the list for completeness, bugs, a better name, etc. A previous thread revealed quite a performance issue with the form plugin's existing serialize function when operating on a form with a large number of elements. My plugin sacrifices semantic order for wicked speed. I have a test form with a select menu containing 500 options -- with the current serializer, it takes around 5 full seconds to do the job, and with mine, it takes about 50 ms. Any feedback would be much appreciated, including whether you think this should be included with the form plugin distribution. Since this isn't a plugin, I'm just going to include the source in this message -- please let me know if there's a better (i.e., more polite) way to do this. Thanks! m. --- $.fn.fastSerialize = function() { var a = []; var f = ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON']; $(f.join(','), this).each(function() { var n = this.name || this.id; var t = this.type; if (!n || this.disabled || t == 'reset' || (t == 'checkbox' || t == 'radio') !this.checked || (t == 'submit' || t == 'image' || t == 'button') this.form.clicked != this || this.tagName == 'SELECT' this.selectedIndex == -1) return; if (t == 'image' this.form.clicked_x) return a.push( {name: n+'_x', value: this.form.clicked_x}, {name: n+'_y', value: this.form.clicked_y} ); if (t == 'select-multiple') { $('option', this).each( function() { if (this.selected) a.push({name: n, value: this.value || $(this).text()}); }); return; } a.push({name: n, value: this.value}); }); return a; }; ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Rev: 259, where is now?
2006/10/3, Andrea Ercolino [EMAIL PROTECTED]: Thanks Franck, but I feel a dummy now. Where is the link to download this 387 version? There's currently no prebuilt jquery.js from svn. You must do it yourself using a svn client. On Windows, you can use TortoireSVN (http://tortoisesvn.net/). But that's not the end. Once you get it, you must install/use ant or make to build jquery. There's a recent thread on this in the mailing list. However and Michael said, you can build it yourself manually. Franck. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] Full featured form validation library in jQuery?
So I've been using a form validation library called TMT_validator for the last year or so. It's very full-featured (probably a little too full-featured for what I need it for). But it's the best one I've found. I just checked the plugins page for form validation libraries and really only found one or two, but they didn't appear very rich. I'm wondering if anyone has form validation done using jQuery? This is what I'm using now: http://www.massimocorner.com/validator/ Anyone care to rewrite it using jQuery? !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] NEWS: JQuery Digg Spy Updated
I saw this on Ajaxian and I'm not sure if its been posted here but this JQuery Digg Spy has been updated: http://leftlogic.com/info/articles/jquery_spy2 Rey.. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Full featured form validation library in jQuery?
Actually I've built a library much like the one you are using for in-house at our company and was thinking about porting it to a jQuery plugin because I haven't seen one like it yet either. -- Brandon On 10/3/06, Andy Matthews [EMAIL PROTECTED] wrote: So I've been using a form validation library called TMT_validator for the last year or so. It's very full-featured (probably a little too full-featured for what I need it for). But it's the best one I've found. I just checked the plugins page for form validation libraries and really only found one or two, but they didn't appear very rich. I'm wondering if anyone has form validation done using jQuery? This is what I'm using now: http://www.massimocorner.com/validator/ Anyone care to rewrite it using jQuery? !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Rev: 259, where is now?
ok Now I understand that there is no release newer thah the 249, which is currently linked as the latest one in jquery.com Would it be possibletopost a build, once in a while? The dev page in jquery.com should bethe right place for a section of this type. LatestRev: 387 (to be built). Previousbuilds follow: ... Rev: 259 - 2006-09-01 02:22:39 -0400 (Fri, 01 Sep 2006) ... Rev: 249 - 2006-08-31 13:26:31 -0400 (Thu, 31 Aug 2006) ... I still don't know where I got this 259, without building it myself /** jQuery - New Wave _javascript_** Copyright (c) 2006 John Resig (jquery.com)* Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses.** $Date: 2006-09-01 02:22:39 -0400 (Fri, 01 Sep 2006) $* $Rev: 259 $*/ - Original Message From: Franck Marcia [EMAIL PROTECTED]To: jQuery Discussion. discuss@jquery.comSent: Tuesday, October 3, 2006 6:36:24 PMSubject: Re: [jQuery] Rev: 259, where is now? 2006/10/3, Andrea Ercolino [EMAIL PROTECTED]: Thanks Franck, but I feel a dummy now. Where is the link to download this 387 version?There's currently no prebuilt jquery.js from svn. You must do ityourself using a svn client. On Windows, you can use TortoireSVN(http://tortoisesvn.net/).But that's not the end. Once you get it, you must install/use ant ormake to build jquery. There's a recent thread on this in the mailinglist. However and Michael said, you can build it yourself "manually".Franck.___jQuery mailing listdiscuss@jquery.comhttp://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Full featured form validation library in jQuery?
One thing I'd also like to request is a complete form widgets plugin. At the moment there are a plethora of form widgets, each of them single plugins. That's not very useful for someone that wants something that gets included once and called multiple times. Ideally, someone would come out with a forms plugin that includes basic validation and error display along with form widgets. !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Brandon Aaron Sent: Tuesday, October 03, 2006 11:51 AM To: jQuery Discussion. Subject: Re: [jQuery] Full featured form validation library in jQuery? Actually I've built a library much like the one you are using for in-house at our company and was thinking about porting it to a jQuery plugin because I haven't seen one like it yet either. -- Brandon On 10/3/06, Andy Matthews [EMAIL PROTECTED] wrote: So I've been using a form validation library called TMT_validator for the last year or so. It's very full-featured (probably a little too full-featured for what I need it for). But it's the best one I've found. I just checked the plugins page for form validation libraries and really only found one or two, but they didn't appear very rich. I'm wondering if anyone has form validation done using jQuery? This is what I'm using now: http://www.massimocorner.com/validator/ Anyone care to rewrite it using jQuery? !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Single Value Attributes
What about you doing something like this: $.fn.checked = function(b) { b this.attr('checked', 'checked') || this.removeAttr('checked'); } but doing this we counting on both *attr* and *removeAttr* methods return *true* on success (at least *attr* method). John Resig wrote: $.fn.checked = function(b) { if ( b ) this.attr( checked, checked ); else this.removeAttr( checked ); }; What do you think? --John -- View this message in context: http://www.nabble.com/Single-Value-Attributes-tf2373768.html#a6618527 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Single Value Attributes
I strongly suggest you to compare if a variable is equal to undefined using the typeof unary operator, because if you, someday, dicide to get these things work on IE 5, you can not compare to the undefined constant (?), after all, it doesn't exist on IE 5.0. Compare like this one: if(b || typeof b == 'undefined') { ... John Resig wrote: Sure, makes sense to me: $.fn.checked = function(b) { if ( b || b == undefined ) this.attr( checked, checked ); else this.removeAttr( checked ); }; --John -- View this message in context: http://www.nabble.com/Single-Value-Attributes-tf2373768.html#a6618812 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] Sortable Puzzle?
Hello,Is it possible to create a Sortable Puzzle with jQuery (probably using Interface) to create something like this: http://wiki.script.aculo.us/scriptaculous/page/print/SortableFloatsDemothanks,Dominik___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Full featured form validation library in jQuery?
That's a lot of stuff! Seriously, I think that what is being requested here, more than anything else, is organization. Can we start grouping our code into plugin packs, or something? One for forms and friends, one for all kinds of visual effects (perhaps a package that groups the best of the best visual plugins with Interface?), one for language extensions, and so on. It might even be a Good Thing to version them, and pack them to save space. There are a lot of really great plugins here, but they're not as easily accessible as they can be. For everyone else: All these plugins are done on a largely volunteer basis. This is an unfunded, we-do-this-because-we-love-it open source project. Generally, our response to I need ___ is Great! I can't wait to see how it looks after you've written it! So, don't expect anything huge to be done upon request. But, a lot of useful plugins are already rolling around here. So, don't despair. :) - Brian One thing I'd also like to request is a complete form widgets plugin. At the moment there are a plethora of form widgets, each of them single plugins. That's not very useful for someone that wants something that gets included once and called multiple times. Ideally, someone would come out with a forms plugin that includes basic validation and error display along with form widgets. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Serializing XML
I wasn't claiming that for was any less great than each! I was complaining about looping a concat vs. doing a join at t the end... and other micro effeciencies. I gave up tiny-tuning code when I gave up assembler. I tell this to all my programmers, You can't compare a little application code time to the time it takes to do a big IO (or http or sql...). I tend to be opinionated about certain things... I am an XSL guy, I don't like incrementing! (a for loop works when there is little else!) On 10/3/06, Christof Donat [EMAIL PROTECTED] wrote: Hi, I like optimized code as much as the next guy... but brevity and readability is KEY. the milliseconds that you can save using one reasonable technique vs. another are not comparable to the seconds it takes for an http request. Is this about my suggestion to use for() instead of each()? If not, my code is not noticably longer than Marks. I also don't think that it is less readable. If you are just talking about the for()-each() stuff. Both have their advantages and their disadvantages. If it is the inner loop of a function you expect to call often, you may whant to pay the price of less readability and brevity for the performance of for(). I never liked using XMLSerializer because [...] It can be quite usefull with XMLHttpRequests when your protocol is XML-based. But that was not the question here, was it? Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- Ⓙⓐⓚⓔ - יעקב ʝǡǩȩ ᎫᎪᏦᎬ ▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒ ░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░ ▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒ ░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░ ▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Full featured form validation library in jQuery?
The jquery.com plugins page has a couple validators listed: Form Validation (no AJAX) http://fuzz.bassistance.de/jQueryFormValidation/validateTest.html Add validation rules to your markup and apply the form plugin to your form. Work is still in progress. Have a look at the different examples to see how the plugin can be applied and customized. Jörn Zaefferer Simple Form Validator http://www.willjessup.com/sandbox/jquery/form_validator/ form_validate.html Use both server side and JavaScript validators (and write your own) in an easy to use plugin. will jessup but maybe they're not full-featured enough? Cheers, Karl ___ Karl Swedberg www.englishrules.com www.learningjquery.com On Oct 3, 2006, at 12:50 PM, Brandon Aaron wrote: Actually I've built a library much like the one you are using for in-house at our company and was thinking about porting it to a jQuery plugin because I haven't seen one like it yet either. -- Brandon On 10/3/06, Andy Matthews [EMAIL PROTECTED] wrote: So I've been using a form validation library called TMT_validator for the last year or so. It's very full-featured (probably a little too full-featured for what I need it for). But it's the best one I've found. I just checked the plugins page for form validation libraries and really only found one or two, but they didn't appear very rich. I'm wondering if anyone has form validation done using jQuery? This is what I'm using now: http://www.massimocorner.com/validator/ Anyone care to rewrite it using jQuery? !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] XPath expressions not working
I've been testing and I see many really simple XPath queries that just don't work, or they even break. Is this broken in jQuery? Are they working for somebody? thanks ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] XPath expressions not working
Raziel Alvarez schrieb: I've been testing and I see many really simple XPath queries that just don't work, or they even break. Is this broken in jQuery? Are they working for somebody? jQuery does not claim to implement the XPath standard. It just supports a small subset, and these should work. Could you provide more specific examples that don't work? -- Jörn ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] How should :nth-of-type work?
I use to have all the *type selectors implemented, but after a quick survery I couldn't find anyone who actually used them (and who could've just used :nth-child() instead). Although, its' probably a good idea to have these in an external plugin, for completeness, in case anyone wants them. Good work George. --John Good point J?rn, thank you. (I've not found a good use for :nth-of-type() myself, but someome will!) More interesting as it turns out, is the :nth-sibling-of-type() selector that I created accidentally... It turns out to be a simple way of returning TD elements in the same column of a table. Here are two examples on a form and a table: http://www.softwareunity.com/sandbox/JQueryMoreSelectors/nth-of-type/ Original test page is here: http://www.softwareunity.com/sandbox/JQueryMoreSelectors/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Rev: 259, where is now?
I do have one pre-built one that I re-generate every couple days, you can find it here: http://jquery.com/src/jquery-svn.js Having a nice historical listing would be nice too, as you suggest - but this should be good for now. --John On 10/3/06, Andrea Ercolino [EMAIL PROTECTED] wrote: ok Now I understand that there is no release newer thah the 249, which is currently linked as the latest one in jquery.com Would it be possible to post a build, once in a while? The dev page in jquery.com should be the right place for a section of this type. Latest Rev: 387 (to be built). Previous builds follow: ... Rev: 259 - 2006-09-01 02:22:39 -0400 (Fri, 01 Sep 2006) ... Rev: 249 - 2006-08-31 13:26:31 -0400 (Thu, 31 Aug 2006) ... I still don't know where I got this 259, without building it myself /* * jQuery - New Wave Javascript * * Copyright (c) 2006 John Resig (jquery.com) * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * * $Date: 2006-09-01 02:22:39 -0400 (Fri, 01 Sep 2006) $ * $Rev: 259 $ */ - Original Message From: Franck Marcia [EMAIL PROTECTED] To: jQuery Discussion. discuss@jquery.com Sent: Tuesday, October 3, 2006 6:36:24 PM Subject: Re: [jQuery] Rev: 259, where is now? 2006/10/3, Andrea Ercolino [EMAIL PROTECTED]: Thanks Franck, but I feel a dummy now. Where is the link to download this 387 version? There's currently no prebuilt jquery.js from svn. You must do it yourself using a svn client. On Windows, you can use TortoireSVN (http://tortoisesvn.net/). But that's not the end. Once you get it, you must install/use ant or make to build jquery. There's a recent thread on this in the mailing list. However and Michael said, you can build it yourself manually. Franck. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ 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/
Re: [jQuery] XPath expressions not working
I sent an email yesterday, but maybe it didn't got through. Anyway, this is it: I have this simple markup: componentDom.innerHTML = form action=""> h1 name=formTitle/h1 p name=formInstructions/p div name=top /div div name=formContent divname=columndiv /div/div /div div name=bottom input type=submit name=defaultButton value=Submit/ /div/form I'm executing this xpath calls with the following results: $('form/[EMAIL PROTECTED]', componentDom).length = 3 $('form/[EMAIL PROTECTED]', componentDom)[0].innerHTML = $('form/[EMAIL PROTECTED]', componentDom)[1].innerHTML= DIV name=\column\DIV/DIV/DIV $('form/[EMAIL PROTECTED]', componentDom)[2].innerHTMLINPUT type=submit value=Submit name=defaultButton $('form/[EMAIL PROTECTED]/input', componentDom)Object requiredError $('//div', componentDom)'undefined' is null or not an objectError $('form//div', componentDom).length= 6 $('form//div/input', componentDom).length= Object requiredError I don't understand why it's failing. I'm just asking for the input which it's obviously there, under the last DIV. Like this, I've come across many really simple XPath queries that just don't work. Am I doing something wrong? Is it XPath actually supported? Moreover: Thos queries that return an error, like: $('form//div/input', componentDom); break in the siblingfunction(elem, pos, not) since elem is null. Probably this is related to the bug where children() breaks when there are no children. I know jQuery doesn't support the full XPath standard but as you can see my expressions are really simple, andanyway it shouldn't break. Thanks On 10/3/06, Jörn Zaefferer [EMAIL PROTECTED] wrote: Raziel Alvarez schrieb: I've been testing and I see many really simple XPath queries that just don't work, or they even break. Is this broken in jQuery? Are they working for somebody?jQuery does not claim to implement the XPath standard. It just supportsa small subset, and these should work. Could you provide more specific examples that don't work?-- Jörn___jQuery mailing list discuss@jquery.comhttp://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Single Value Attributes
leandro nascimento camarg schrieb: I strongly suggest you to compare if a variable is equal to undefined using the typeof unary operator, because if you, someday, dicide to get these things work on IE 5, you can not compare to the undefined constant (?), after all, it doesn't exist on IE 5.0. Compare like this one: if(b || typeof b == 'undefined') { ... Well, there is this fix: window.undefined = window.undefined; So far everything seems to work in IE5.5. Any IE versions lower than that won't be supported anyway, there are too many limitations on calling functions with a certain context, if I remember that right. In case you are interested, in this closed bug report is most of the stuff documented: http://jquery.com/dev/bugs/bug/96/ -- Jörn ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Serializing XML
Hi, I wasn't claiming that for was any less great than each! I was complaining about looping a concat vs. doing a join at t the end... Erm, did I discuss that somewhere? You answered to my posting. The concat vs. join stuff was Sam. My point was to take the check for XMLSerializer out of the function by emulating it when it is not yet implemented. That is not only a little bit faster. It is a more general solution which is much more important than the rather marginal speedup. and other micro effeciencies. I gave up tiny-tuning code when I gave up assembler. There are situations where you need speed optimizations. Especially with languages like JavaScript, where some interpreters are really slow, it happens as soon as you work with big datasets. I like to spot eventual performance improvements to keep me trained for the cases I need to. I tell this to all my programmers, You can't compare a little application code time to the time it takes to do a big IO (or http or sql...). It all depends on how often you run the loop and how much overhead the optimization needs. If the loop costs maybe 10 bytes of JS-code and is run some 1 times the optimization will probably pay. Of course a optimization in one function that slows down other stuff so much that the complete system gets slower is no real optimization. I tend to be opinionated about certain things... I am an XSL guy, I don't like incrementing! (a for loop works when there is little else!) As I said: With such a simple function in each() you might also consider to use a normal for-loop. Note simple function and might consider. I think we actually do agree here: for() is OK in such simple cases if performance matters. In more complicated cases each() makes the code better readable. I also think that Sams optimization is OK, if performance matters (i.e. the function is called very often with huge datasets). Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Single Value Attributes
John Resig schrieb: John, these are great additions, but please be advised that in some browsers this.attr('checked', 'checked') won't work as expected. Do you know which browsers those are offhand? It'll help me to test the methods, when I make them I think there are overall inconstencies. I put up a test page: http://stilbuero.de/demo/jquery/checkbox.html There's no checked attribute in the HTML source. In Firefox if you set the checked attribute via attr the checkbox gets checked alright but removeAttr('checked') does not remove the checked state. I found in general that it's better for all those boolean attributes to set/unset the boolean value. HTH, Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Single Value Attributes
$.fn.checked = function(b) { if ( b || b == undefined ) this.attr( checked, checked ); else this.removeAttr( checked ); }; I strongly suggest you to compare if a variable is equal to undefined using the typeof unary operator, because if you, someday, dicide to get these things work on IE 5, you can not compare to the undefined constant (?), after all, it doesn't exist on IE 5.0. Compare like this one: if(b || typeof b == 'undefined') { ... No need to go to the extra work. jquery.js begins with this: window.undefined = window.undefined; So undefined exists in every browser. This is a handy line of code to put in any JavaScript - it's completely compatible with both old and new browsers. -Mike ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Rev: 259, where is now?
thanks John! That's what I was after. - Original Message From: John Resig [EMAIL PROTECTED]To: jQuery Discussion. discuss@jquery.comSent: Tuesday, October 3, 2006 8:27:44 PMSubject: Re: [jQuery] Rev: 259, where is now? I do have one pre-built one that I re-generate every couple days, youcan find it here:http://jquery.com/src/jquery-svn.jsHaving a nice historical listing would be nice too, as you suggest -but this should be good for now.--JohnOn 10/3/06, Andrea Ercolino [EMAIL PROTECTED] wrote: ok Now I understand that there is no release newer thah the 249, which is currently linked as the latest one in jquery.com Would it be possible to post a build, once in a while? The dev page in jquery.com should be the right place for a section of this type. Latest Rev: 387 (to be built). Previous builds follow: ... Rev: 259 - 2006-09-01 02:22:39 -0400 (Fri, 01 Sep 2006) ... Rev: 249 - 2006-08-31 13:26:31 -0400 (Thu, 31 Aug 2006) ... I still don't know where I got this 259, without building it myself /** jQuery - New Wave _javascript_** Copyright (c) 2006 John Resig (jquery.com)* Dual licensed under the MIT (MIT-LICENSE.txt)* and GPL (GPL-LICENSE.txt) licenses.** $Date: 2006-09-01 02:22:39 -0400 (Fri, 01 Sep 2006) $* $Rev: 259 $*/ - Original Message From: Franck Marcia [EMAIL PROTECTED] To: jQuery Discussion. discuss@jquery.com Sent: Tuesday, October 3, 2006 6:36:24 PM Subject: Re: [jQuery] Rev: 259, where is now? 2006/10/3, Andrea Ercolino [EMAIL PROTECTED]: Thanks Franck, but I feel a dummy now. Where is the link to download this 387 version? There's currently no prebuilt jquery.js from svn. You must do it yourself using a svn client. On Windows, you can use TortoireSVN (http://tortoisesvn.net/). But that's not the end. Once you get it, you must install/use ant or make to build jquery. There's a recent thread on this in the mailing list. However and Michael said, you can build it yourself "manually". Franck. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/-- John Resighttp://ejohn.org/[EMAIL PROTECTED]___jQuery mailing listdiscuss@jquery.comhttp://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Single Value Attributes
John, these are great additions, but please be advised that in some browsers this.attr('checked', 'checked') won't work as expected. Do you know which browsers those are offhand? It'll help me to test the methods, when I make them I think there are overall inconstencies. I put up a test page: http://stilbuero.de/demo/jquery/checkbox.html Also notice that .innerHTML (and thus jQuery's .html() method) doesn't always return the live checked state. In IE it tracks any dynamic changes to the script, but in Firefox it only reflects the initial state from the source. You can see the form text by putting this into the URL: javascript:alert(document.getElementsByTagName(form)[0].innerHTML) ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Single Value Attributes
Ah, this isn't a browser bug, but something of a jQuery one. removeAttr does obj.removeAttribute(checked) under the hood, which is not sufficient to remove these built-in properties. It would have to do obj.checked = undefined; or some such under the hood. --John On 10/3/06, Klaus Hartl [EMAIL PROTECTED] wrote: John Resig schrieb: John, these are great additions, but please be advised that in some browsers this.attr('checked', 'checked') won't work as expected. Do you know which browsers those are offhand? It'll help me to test the methods, when I make them I think there are overall inconstencies. I put up a test page: http://stilbuero.de/demo/jquery/checkbox.html There's no checked attribute in the HTML source. In Firefox if you set the checked attribute via attr the checkbox gets checked alright but removeAttr('checked') does not remove the checked state. I found in general that it's better for all those boolean attributes to set/unset the boolean value. HTH, Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Single Value Attributes
Also notice that .innerHTML (and thus jQuery's .html() method) doesn't always return the live checked state. In IE it tracks any dynamic changes to the script, but in Firefox it only reflects the initial state from the source. You can see the form text by putting this into the URL: javascript:alert(document.getElementsByTagName(form)[0].innerHTML) That's just weird. I've never seen a bug like that before. Although, even Firebug doesn't display the checked state so it must be a global thing. --John ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/