No idea?
Le 9 févr. 07 à 10:07, Nicolas Hoizey a écrit :
> Hello,
>
> Let's say I have the folowing code I can't change (it's not mine) :
>
> <select name="myselect"
> onchange="this.nextSibling.visibility='hidden';">
> <option value="1">One</option>
> <option value="2">Two</option>
> </select>
>
> How can I put my own "change" event handler, but being able to run
> the original one as well?
>
> I tried that :
>
> $(document).ready(function() {
> var currentOption = $('[EMAIL PROTECTED] myselect] > option
> [EMAIL PROTECTED]').attr('value');
> var currentOnChange = $('[EMAIL PROTECTED]').attr('onchange');
> currentOnChange = currentOnChange.replace('/this/', '$(\'select
> [EMAIL PROTECTED]')');
> $('[EMAIL PROTECTED] myselect]').removeAttr('onchange');
> $('[EMAIL PROTECTED] myselect]').bind('change', function(event) {
> if (confirm('Are you sure?')) {
> eval(currentOnChange);
> } else {
> $('[EMAIL PROTECTED] myselect] > [EMAIL
> PROTECTED]').removeAttr
> ('selected');
> $('[EMAIL PROTECTED] myselect] > [EMAIL
> PROTECTED]'+currentOption
> +']').attr('selected', 'selected');
> }
> });
> });
>
> The eval doesn't seem to do anything. Any idea how to do this?
>
>
> On a side note, I noticed that I had to use removeAttr() instead of
> unbind(), which was not doing anything.
>
>
> -Nicolas
>
> --
> Nicolas "Brush" HOIZEY
> Clever Age : http://www.clever-age.com/
> Gastero Prod : http://www.gasteroprod.com/
> Photos : http://www.flickr.com/gp/[EMAIL PROTECTED]/M1c002
> phpHeaven : http://www.phpheaven.net/
>
>
>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
-Nicolas
--
Nicolas "Brush" HOIZEY
Clever Age : http://www.clever-age.com/
Gastero Prod : http://www.gasteroprod.com/
Photos : http://www.flickr.com/gp/[EMAIL PROTECTED]/M1c002
phpHeaven : http://www.phpheaven.net/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/