Actually the only thing that gets added to elements (apart from the
usual event handlers) is a jQuery123123234124 type attribute. The data
itself is stored in a separate store, away from the DOM elements. This
is also helps deal with memory leakage problems. So no, no "global
namespace pollution". The only things exposed to the JavaScript
"global namespace" is jQuery and $.

The "corruption" of 'this', as we've explained, isn't a "corruption".
It's what's expected my most JavaScript programmers because that's the
way the old "onclick=...." style handlers work.

*shrug* It's all about how you expect things to work.

Karl Rudd

On Thu, Mar 5, 2009 at 8:25 AM, Michael <dmgx.mich...@gmail.com> wrote:
>
> And jQuery docs criticize prototype for polluting the global namespace
> and in the same breath recommend binding element properties that would
> normally go on a class to elements with all the potential namespace
> collisions that brings?
>
> O... K...... (backs away slowly).
>
> Honestly, the more I use this framework the less I like it.  The
> corruption of 'this' is a major flaw in the framework I don't think
> I'll ever be happy with.
>
> On Mar 3, 10:32 pm, Dave Methvin <dave.meth...@gmail.com> wrote:
>> > one area of functionality has me befuddled
>> > - using object methods to handle events.
>>
>> To continue Karl's point, if you use jQuery the same way you would use
>> prototype then you'll be fighting it all the way. The prototype
>> solution squirrels away references to the DOM objects in the class and
>> then points event handlers back to the class. jQuery usually
>> encapsulates the data and events within the DOM element or a closure,
>> e.g.:
>>
>> $("selector")
>>   .data("options", {answer: 42})
>>   .click(function(){
>>      alert($(this).data("options").answer)
>>   });

Reply via email to