Thanks for that Rick!
Yes, it works but this way is too heavy with the setInterval/
setTimeout: I need to do that on the fly, and I can have tens of
elements using this behavior.

Actually, I'd better explain what I am trying to achieve here: maybe
you're aware of an issue with IE6 where the SELECT elements can't be
overlayed by a DIV with a superior zIndex.
There are 2 ways to avoid this problem: hiding all the select below
the DIV or using "fake" selects instead. It is this solution that I
want to adopt, but I still want my fake select fields to react
correctly to the jQuery val() function. This, used with the field ID,
will change the value of a hidden field, and when this field changes,
I want the corresponding action to be triggered on my fake select.
So if with val() I change the value of my field, the corresponding
text will be visible in my fake select, and in the list this item will
have been replaced by the previous value...

The code I have added in the val() function is, I think, the most
efficient way for being able to trigger the change function on any
hidden field. However, as I love jQuery and hate to have my own
twisted script instead of the standard, I wonder if people think it
could be implemented in the core or if someone would have a better
global solution to that problem...

Cheers!

On Jun 17, 2:40 pm, Rick Waldron <waldron.r...@gmail.com> wrote:
> Take a look here:
>
> http://jsbin.com/ayivo
>
> I've commented the steps I took. Its a bit hackish but the behaviour is what
> you're looking for. I'm sure a better way exists.
>
> Rick
>
> On Wed, Jun 17, 2009 at 8:01 AM, BaBna <thomas.na...@gmail.com> wrote:
>
> > Hi,
>
> > I would like to be able to trigger a function when the value of a
> > hidden field is changed through val() - and I want this event to be
> > attached to the field itself, not to the val() action.
> > As events are only users' triggered a hidden field doesn't trigger
> > onchange natively. I have seen a lot of implementations using various
> > plug-ins for mutation events, but was not very happy about them -
> > they're heavy and I got some errors.
> > Therefore I have added a line at the very end of the val() function:
>
> >                        if(o.nodeName(this,"select")){
> > ...
> >                        }
> >                        else{
> >                                this.value=K;
> > // Here's my line:
> >                                if(this.type=='hidden'){$(this).change()}
> >                        }
> >                }
> >        }
> > )}
>
> > That works fine in IE6, FF and Chrome - haven't tested on other
> > browser.
> > Would it be useful to add this?
>
> > Thanks!
>
> > Here's an example:
> > <html>
> > <head>
> > <script type="text/javascript" src="_shared/js/jquery-1.3.2.min.js"></
> > script>
> > <script type="text/javascript">
> > $(function(){
> >        $("#hiddenField").change(function(e){
> >                alert($(this).val());
> >        });
> >        setTimeout('$("#hiddenField").val("wooloo");',2000);
> > });
> > </script>
> > </head>
> > <body>
> > <input type="hidden" id="hiddenField" value="BaBna" /><br />
> > </body>
> > </html>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to