Thanks for that plugin : ).

Call / apply are ones best friends when working with JS. Incredibly powerful stuff when used right. One of my favorite uses apply is to use it on a new array instance to force 'arguments' variable to behave like a real array and re-route function arguments based on the first value passed into the array:

Sample:
-------------------------------------------------------------------------------------------
$.fn.task = function(fct) {
    var r = $.fn.task.fn[fct].apply(this[0], [].slice.call(arguments, 1));

    return r === undefined ? this : r;

};

$('tr[td]').task('field', 'value'); -> calls
$.fn.task.fn.field(value)
-------------------------------------------------------------------------------------------

Anyway, keep up the good work and thanks for the improvement,
-- Felix
--------------------------
My latest blog posts:

ThinkingPHP and beyond

My Business: http://www.fg-webdesign.de



Josh Bush wrote:
Hey guys and gals.  I learned about the .call() functionality today
and decided to modify the behavior of the optional mask completed
function.  Now you don't need to specify an parameter when you define
your function; you can simply use "this".

Before:
$("#product").maskedinput("99/99/9999",{completed:function(input)
{alert("You typed the following: "+input.val());}});

Now:
$("#product").maskedinput("99/99/9999",{completed:function()
{alert("You typed the following: "+this.val());}});

It's not a necessary change, I just wasn't happy with forcing the user
to add a param to their functions.  It seemed a bit kludgey to me.

The new version is up at: http://digitalbush.com/projects/masked-input-plugin
and also at the official jQuery plugin repository:
http://jquery.com/plugins/project/maskedinput

Thank You
Josh


  

Reply via email to