When I try to bind events like within ajax call:

$.ajax({
                type: 'POST',
...........................

                success: function(msg) {

                     $("#dmid img", msg).each ( function() {

                     $(this).bind('mouseover', handler)
...............................

problem is the event is not bound   unless I do something like:
$('#firstdiv').html(msg)
$("#dmid img").each ( function() {
        $(this).bind('mouseover', handler)


Any idea why we cannot bind events when context is  other than the
current loaded document?


Another question:
I have the option of writing onclick events  within HTML page like:

<imgg src=""   onclick=" return  imghandler(event);" >
<imgg src=""   onclick=" return  imghandler(event);" >
<imgg src=""   onclick=" return  imghandler(event);" >

or using jquery to bind the onclick events above when the document has
loaded like

$("imgg").each ( function() {
        $(this).bind('mouseover', imghandlerr)
}

Apart from the fact that the page size that is transported from the
server to the client is reduced when using jquery binding of events
( due to missing hard coded onclick handlers in html), are there any
other advantages or disadvantages of either approach?

Reply via email to