Jörn Zaefferer schrieb:
> Some things I noticed:
> - I manged to get a -1 count on the second textarea, mostly by typing 
> wildly in it
> - if(typeof(nr) == "undefined") { nr = 0; } <- that line seems to define 
> a global variable if it isn't set yet, why not just using var nr = 0; ?
> - I'd like to be able to specify the maxlength via a plugin option 
> instead of the attribute
> - there is no need to set the "relatedElement" as an expando property, 
> you can just use a closure to access it from inside the keyup handler, 
> eg. var related = ...; $(...).keyup(function() { /* do something with 
> related */ });
> - you don't need that ID on the counter either, instead create it as: 
> var counter = $(html_counter).insertBefore(this); - then you can use 
> "counter" instead of searching for the id and saving it as relatedElement
> 
> Hope that helps.

What Jörn said about the relatedElement expando applies to the variable 
max as well (and probably just slipped out of his mind), it is defined 
twice where it needn't be, because via the closure all variables are 
already in the scope. So you don't need to declare var max and var 
maxLength a second time, instead just stick to max.

I second the need to define the maximum length as an option, simply 
because there is no maxlength attribute for the textarea element, thus 
it's invalid HTML and maybe even clash with a future Web Forms 
specification.

Another idea: Why not using an <em> element to hold the counter? To me 
such thing would need to be emphasized a bit. Put in some more 
semantics! You could also use a label element that is associated with 
the textarea, which also makes sense (or even both).

Just a few ideas...


-- Klaus





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

Reply via email to