views:

202

answers:

1

I saw the answer of a question: http://stackoverflow.com/questions/2443490/add-jquery-colorbox-plugin-to-a-dynamically-created-element

Solve part of the problem, works fine, but when I click for second time, it doesn't work. When I try to click for second time an error displays: $.fn.colorbox is not a function. How can i correct that error and avoid a double click to bind colorbox.

I don't speak english, i did my best to write this words, i hope you can read me. Thanks.

A: 
$('.colorbox').die().live('click', function() {
  $.fn.colorbox({href:$(this).attr('href'), open:true});
  return false;
}

That should help you put a ".die()" before the ".live("

Val
I tryed, but it does the same: $.fn.colorbox is not a function
PapiChuloMX
that case it means that javascript cannot find the function. there are two reasons for this. `A`: if the colorbox is not loaded. `B`: Because you have made a scripting error and the function seems like it doesn't exist. `so` check that you have the colorbox as a function or debug ur script.
Val
My mistake, works fine, thank you
PapiChuloMX
ah nice this works except it does not work with grouped elements.
Chris
you can try die('click'). which will kill only the on click functions for that element and ignore the rest.
Val