0

How do I target a div that is dynamically created on mousedown and mousemove and then removed on mouseup?

I have tried to target it like so:

$ ('div').on('remove', '.ui-draggable-dragging', function(e){
      console.log('hello world');
    });

This div only happens when a box is created by another js script. Thanks for your help.

  • Can you add other code, like the html you are using? Perhaps also creat a jsFiddle for us? – Andy Holmes Oct 25 '13 at 10:44
  • I would, but I'm not sure I can share this site. It's my companies site and the page is dynamically created by xml that we write. This a "style" that was created as an image map. Meaning a respondent can draw a box for each section of an image they like. I have a client that wants to have a popup box happen when a respondent draws a box to ask them why they like that part of the image. – exiledhunter_6 Oct 25 '13 at 11:18

2 Answers2

0

try this. If .ui-draggable-dragging is dynamically created you need to search the body for it before doing anything:

$('body').on('remove', '.ui-draggable-dragging', function (e) {
    console.log('hello world');
});
Andy Holmes
  • 7,817
  • 10
  • 50
  • 83
0

You should try to inspect change on a higher element in the DOM like

$('body').on( 'change', '#container', function() {
   dowhatyouneed();
}):
Philippe CARLE
  • 549
  • 3
  • 18