Stephan Beal wrote:
On Jul 22, 2:16 am, barophobia <[EMAIL PROTECTED]> wrote:
I think I understand but how do I handle the #passwordField part
within the plugin?

In your plugin implementation, simply store a reference to the
#passwordField passed to your plugin. For example, if you plugin looks
like this:

jQuery.fn.myPlugin = function(targetField) {
  var self = this;
  self.textfield = jQuery(targetField);
  ... do whatever you normally do ...
  ... updates of the text field are applied to self.textfield ...
  ... you can use self.textfield in inner functions, e.g. those
defined as click() handlers ...
}

Now you can call:

$('#button').myPlugin('#IDForSomeTextField');

IMHO it is bad practice to store that element in the self, i.e. jQuery, object.

You may eventually overwrite a jQuery core or plugin method on that special object. That'll hard to track down.

A simple var should be sufficient.

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


--Klaus

Reply via email to