Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

imagepicker jquery callback clicked

I am using this http://rvera.github.io/image-picker/ library and I don't know how to show the value of the src image when clicked.

Can you help me?

This is my example

$("select.image-picker.show-labels").imagepicker({
  hide_select:  true, 
  show_label:   true,
  clicked:function(){
      console.log($(this).find("img").attr("src"));
  }
});

Thanks

like image 357
jcarlosweb Avatar asked Jun 18 '13 08:06

jcarlosweb


1 Answers

This should do it :

$(this).find("option[value='" + $(this).val() + "']").data('img-src');

$(this) is the select input, you're trying to find the option which is selected and to get the img-src data attribute.

Though, are you sure you shouldn't just get the Id of the image you selected through $(this).val() ?

like image 195
Florian F. Avatar answered Oct 01 '22 16:10

Florian F.