Ok, looked at the event and ajax code.  There's no way to distinguish
targets, as that information is not passed into the $.ajax call and
thus cannot be used when ajax events are triggered.  So, they end up
triggered 'globally', meaning they are made to not bubble and be
called directly upon all elements which have handlers bound for that
event.

I've posted a thread on the dev list to discuss a way to add that info
and trigger the events in more normal fashion:

http://groups.google.com/group/jquery-dev/browse_thread/thread/caf31f67a3ac159c

On Wed, Jul 29, 2009 at 9:39 AM, Nathan Bubna<nbu...@gmail.com> wrote:
> So, you have a page:
>
> <html><head>
> <script type="text/javascript" src="jquery.1.3.2.js"></script>
> <script type="text/javascript">
> $(function() {
>  var onajax = function(e) { alert($(e.target).text()); };
>  var onclick = function(e) { $(e.target).load('foobar'); };
>  $('#a,#b').ajaxStart(onajax).click(onclick);
> });
> </script></head><body>
> <div id="a">foo</div>
> <div id="b">bar</div>
> </body></html>
>
> Would you expect one alert or two when you clicked on 'foo'? I would
> expect just one, but i get two. Why does one event have multiple
> targets? This sure seems to violate the principle of least surprise.
> Am i missing something? Is there a way to distinguish, via the event
> object which div the load() call was made upon? That would sure be
> helpful...
>

Reply via email to