Sunday, December 28, 2008

[jQuery] Re: Disabling behaviour definded in html

That doesn't work. You need to empty the html attribute:

$('#text').attr('onkeyup','')

If you need to recover that behavior later, save it with the data()
function:

(verbose example)
$.fn.disableBehavior = function(event){
return this.each(function(){
var t = $(this);
if (!t.data(event)) $(this).data(event, this.attr(event)).attr
(event,'');
});
};

$.fn.enableBehavior = function(event){
return this.each(function(){
var t = $(this);
$(this).attr(event, t.data(event));
});
};

On Dec 28, 6:07 pm, sad1sm0 <john.fan...@gmail.com> wrote:
> I would imagine you should just be able to unbind the onkeyup event
> with .unbind()
> example
> $("#text").unbind('onkeyup');
>
> from there you can attach your own event handlers

No comments: