That could be easily reduced to this:

$.fn.disable = function() {
    return this.attr('disabled', true).addClass('disabled');
}

$.fn.enable = function() {
    return this.removeClass('disabled').attr('disabled', false);
}


On Sep 26, 2:28 pm, livefree75 <[EMAIL PROTECTED]> wrote:
> I actually *JUST* created enable & disable functions:
>
> (function($)  {
>         /**
>          * Disables the matched form elements, and adds the <var>disabled</
> var> class
>          * to them.
>          * @return jQuery The matched elements.
>          */
>         $.fn.disable = function()  {
>                 $(this).each(function()  {
>                         $(this).attr("disabled", true).addClass("disabled");
>                 });     // $(this).each()
>                 return $(this);
>         };      // $.fn.disable()
>
>         /**
>          * Removes the <var>disabled</var> class from the matched form
> elements, and
>          * re-enables them.
>          * @return jQuery The matched elements.
>          */
>         $.fn.enable = function()  {
>                 $(this).each(function()  {
>                         $(this).removeClass("disabled").attr("disabled", 
> false);
>                 });     // $(this).each()
>                 return $(this);
>         };      // $.fn.enable()
>
> })(jQuery);
>
> Enjoy!
>
> Jamie
>
> On Sep 26, 7:55 am, Martin <[EMAIL PROTECTED]> wrote:
>
> > Dear all,
>
> > I like jQuery much but I do not like the way the enabling, disabling
> > elements is handled. This is a pretty common task and the current
> > solution based on changing attributes is not in accord with jQuery’s
> > “write less” philosophy.
> > The enable() / disable() functions would be MUCH more elegant and in
> > light with the jQuery gospel.
> > Could this be included in the next release ?
>
> > Best
> > Martin

Reply via email to