The event code only deals with "unobtrusive" events. If you have an
inline event in the tag, you need to use the attr() method to overwrite
the "onchange" attribute with a blank string. It sounds dumb, and... it
is. But, it works.
$( "#myradiobutton" ).attr( "onchange", "" ).change( function() { ... } );
You can throw in unchange() anyway, for good measure, in case there may be
events registered the not-inline way as well.
This brings up an interesting question. Should un<event> simply deal with
this case? I think that adding .attr( "on<event>", "" ) to each un<event>
would help enforce the Principle of Least Surprise.
- Brian
> I have a number of controls on a form that have a default onchange()
> function. In some places I would like to change the onchange function to
> something else, but I find that I have been unsuccessful in removing the
> default function.
>
> I have tried several different types of commands but nothing seems to
> work.
> Here is what I have so far:
>
> $("#myform").find(".inputbox").unchange().change(function() {
> anotherfunction();
> });
>
>
> <input type="text" name="filter" id="filter" value=""
> class="inputbox" onchange="document.myform.submit();" />
>
> --
> View this message in context:
> http://www.nabble.com/unchange%28%29---how-does-it-work--tf2356323.html#a6563193
> Sent from the JQuery mailing list archive at Nabble.com.
>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/