[jQuery] Event-Handling with bind()

[jQuery] Event-Handling with bind()


Hello,
I try to pass parameters to the Event-Handler. But it does not work
like I want it to work.
The handler holds only the last object that I passed to the Event-
Handler. The following example explains my problem. A click on
'helloP' alerts 'barDiv' and a click on the helloDiv alerts 'barDiv'.
But I want to alert 'barP' when I click on helloP. And I don't want to
use two different handlers.
Kind regards
Andres Koetter
...
<script type="text/javascript">
function handler(event) {
alert(event.data.foo);
}
$(document).ready(function() {
$("p").bind("click", {foo: "barP"}, handler);
$("div").bind("click", {foo: "barDiv"}, handler);
});
</script>
...
<body>

helloP


<div>helloDiv</div>
</body>