[jQuery] click Event Problem with appended html element

2009-11-07 Thread ndes
Hi! I was wondering if i made something wrong or this dont works in
general. I have a drop down list that onChange loads some data an
pops a list of img+text

$('#selectDisplay').change(function(){
.
//LOOP
$(#btnDisplay).append('img class=btnDisp
value='+respObj.jsonarray[i]['id']+' style=vertical-align: bottom;
padding: 0 6px; src=img/fam/add.png /'+respObj.jsonarray[i]['name']
+'br /');
.
});


I also have a general even on $(document).ready(function() {

$('.btnDisp').click(function(){
//DO SOMETHING ex.
alert(working);
});

The problem is that on dynamic generated img's (custom btns) the
onClick Alert doesnt work. But it works on static .btnDisp imgs that
loads with the html...

So what can I do for something like this?
Thanks in advance!


Re: [jQuery] click Event Problem with appended html element

2009-11-07 Thread Leonardo K
Look the live event: http://docs.jquery.com/Events/live#typefn

On Sat, Nov 7, 2009 at 10:49, ndes fevga...@gmail.com wrote:

 Hi! I was wondering if i made something wrong or this dont works in
 general. I have a drop down list that onChange loads some data an
 pops a list of img+text

 $('#selectDisplay').change(function(){
 .
 //LOOP
 $(#btnDisplay).append('img class=btnDisp
 value='+respObj.jsonarray[i]['id']+' style=vertical-align: bottom;
 padding: 0 6px; src=img/fam/add.png /'+respObj.jsonarray[i]['name']
 +'br /');
 .
 });


 I also have a general even on $(document).ready(function() {

 $('.btnDisp').click(function(){
 //DO SOMETHING ex.
 alert(working);
 });

 The problem is that on dynamic generated img's (custom btns) the
 onClick Alert doesnt work. But it works on static .btnDisp imgs that
 loads with the html...

 So what can I do for something like this?
 Thanks in advance!