Hello I'm creating a plugin that enhances an input element in a form. The plugin makes use of, among other things, the keydown event.
The problem I'm seeing is that when I run: $.fn.myPlugin = function(e) { return this.each(function() { $input = $(this); $input.keydown(myFunction); }); }; $('#x').myPlugin(); $('#y').myPlugin(); 'myFunction' is run several times when I press a key in one of the input elements. I've tried looking at the ui.datepicker plugin that seems to work as I want it too, but it's much too complex for me to derive an approach out of. Could anyone _please_ help me by providing a scaled down example of an approach that will allow every instance of my plugin to keep it's local settings and reference to input element (or best practice on how you would solve this problem). (I am also adding some wrapping the input element in a div and adding a few more inputs to it, how I'm supposed to be keeping track of that group and registering events on objects in it would be a great addition, but I left it out of my original problem description to keep it simple(r)) Thanks in anticipation!