Dynamic Div not found in selector

Dynamic Div not found in selector

I have dynamic divs being added to a contianer.  I create them like this

  1.  $(document).ready(function() {
  2.             buildDiv(3, 3, 128, 128, 'smile_face.png');
  3.           

  4.         });
  5.             
  6. function buildDiv(x, y,width,height, img) {
  7.             var ele = $(document.createElement('div'));
  8.             ele.css('top', (x * 128) + 'px');
  9.             ele.css('left', (y * 128) + 'px');
  10.             ele.css('width', width + 'px');
  11.             ele.css('height', height + 'px');
  12.             ele.css('z-index', 0);
  13.             ele.css('background-image', 'url(\'' + img + '\')');
  14.             ele.css('position', 'absolute');
  15.             $('.mapContainer').append(ele);

  16.             ele = $(document.createElement('div'));
  17.             ele.css('top', (x * 128) + 'px');
  18.             ele.css('left', (y * 128) + 'px');
  19.             ele.css('width', width + 'px');
  20.             ele.css('height', height + 'px');
  21.             ele.css('z-index', 5000);
  22.             ele.css('position', 'absolute');
  23.             ele.addClass('clickable');
  24.             ele.attr('id', toStore(x, y));
  25.             $('.mapContainer').append(ele);
  26.        
  27.         }
  28.       function toStore(x, y) {
  29.             return (x << 8) ^ y;
  30.         }



I think have a selector which looks like this

  1. $(".clickable").click(
  2.             function() {
  3.                   alert('CLICKED');
  4.             });

The problem is when the dynamic DIV is added to the form, it shows up but is not clickable.  The event is never called.  When a div is added with the class clickable on page load, the event is triggered.

Im guessing there is some way to add an element to the clickable selector but I can not figure it out.  

Thank you.