So in real browsers, if you bind something to an element's click event, your handler returns false in order to stop the even bubbling. It's fairly simple.
In jQuery, for example,
This essentially hijacks the click and replaces the default behaviour with whatever you code.
On form elements, it's the same.
The catch here is that you don't need to return false because you don't need to prevent an action such as an anchor's page location change. This caught me out because in real browsers it doesn't matter, but in Internet Explorer the event fires for every element in the radio group, or the existing and new options in a select box. Returning false, in essence, tells IE to move on to the next element's event. So don't do it. Either return true or - simpler - just don't return anything. Then IE will behave like the rest of the world.
In jQuery, for example,
$('a.thingy').click(function(){
// do something
return false'
});
This essentially hijacks the click and replaces the default behaviour with whatever you code.
On form elements, it's the same.
$('input[type=radio]').change(function(){
// do something
return false;
});
The catch here is that you don't need to return false because you don't need to prevent an action such as an anchor's page location change. This caught me out because in real browsers it doesn't matter, but in Internet Explorer the event fires for every element in the radio group, or the existing and new options in a select box. Returning false, in essence, tells IE to move on to the next element's event. So don't do it. Either return true or - simpler - just don't return anything. Then IE will behave like the rest of the world.
0 Comments On This Entry
Tags
My Blog Links
Recent Entries
-
It's good to re-implement sites. Say it with me, "this time, I'll do it right"
on Dec 23 2010 03:39 AM
-
-
-
-
Recent Comments
-
Munawwar
on Dec 23 2010 05:31 AM
It's good to re-implement sites. Say it with me, "this time, I'll do it right"
-
-
-
-
Search My Blog
0 user(s) viewing
0 Guests
0 member(s)
0 anonymous member(s)
0 member(s)
0 anonymous member(s)
|
|



Leave Comment








|