On Jul 22, 11:57 pm, Klaus Hartl <[EMAIL PROTECTED]> wrote:
> IMHO it is bad practice to store that element in the self, i.e. jQuery,
> object.
...
> A simple var should be sufficient.
>
> jQuery.fn.myPlugin = function(targetField) {
>      var textfield = jQuery(targetField);
>      ...
>
> };

Assuming we need to hold on to the target long-term (e.g., in inner
functions or even classes), would this be a more acceptable approach
to using self to sort the jQuery object:

jQuery.fn.myPlugin = function(targetField) {
    var self = this;
    self.target = targetField;
...
    var textfield = jQuery(self.target);
      ...
};

?

The difference is that this one is holding the selector string, and
not the jQuery object (unless, of course, the user passes a jQ as
targetField).

Reply via email to