views:

66

answers:

2

I've got this DOM:

<li>
    <img class="ui-selectee" src="../img/thumbs/80x80_1280_wallpaper.jpg" style=""/>
    <input type="hidden" value="3"/>
    <a class="btnImgDel" title="Eliminar" href="javascript:void(0)">Eliminar</a>
    <a class="btnImgRen" title="Renombrar" href="javascript:void(0)">Renombrar</a>
    <a class="btnImgZoom" title="Ampliar" href="javascript:void(0)">+</a>
</li>

Links do not cover all the image, but only some pixels.

As you may notice, the img is selectable (jQuery UI) and it's got three links as siblings. These links should run a function when clicked:

$('.btnImgDel').live('click',function(){
    $('#dialogDeleteImg').dialog('open');
    console.log('click');
});

However, when I click over a link nothing happens. Links have greater z-index and are visible.

Any way to make this work or any clue about what may be going on?

A: 

Did you put your code inside $(document).ready()?

Also you can try:

$(document).ready(function() {
  $('.btnImgDel').click(
    function(){
      $('#dialogDeleteImg').dialog('open');
      console.log('click');
    });
});

or this

<span class="btnImgDel" title="Eliminar">Eliminar</span>
eKek0
Yes, it is inside $(document).ready().I cannot use $('.btnImgDel').click(). a.btnImgDel are being created dynamically, that is why i'm using live()
Gerardo
It works just fine when not using live (though I do need it)
Gerardo
+2  A: 

put the console.log before the dialog() it could be failing on that.

also, no need for the href's with javascript.

<a href="#"></a>

$(".btnImgDel").click( function(event) {

   event.preventDefault();

});
Chad Grant
Yep, that's the solution. He's using the live method but you get the idea across and that's what matters IMO. ;) Just as note... you can use 'return false;' instead of 'event.preventDefault()'--it's less typing.
KyleFarris
I've had problems with return false cross browser so have switched to preventDefault() and have had no issues. ;)
Chad Grant