0

When I try jQuery selector after append html element, event is not working but when all page loaded and I try again selector like drag-drop or click event anything else it's working. I used setTimeout function trying this event after 3 seconds its okay but I don't want to do this. Do we have another way? I'm working with Google Chrome.

$('#conf'+objId).on('toolbarItemClick',  function(event,buttonClicked){

    var itemId=buttonClicked.id;

    var clickedItemId=event.target.id.slice(4); 

    var _obj=getObjectById(clickedItemId);

    switch (itemId) {
    case 'objeEdit':
        editBoxNameDialog(clickedItemId,"obj",_obj);
    break;
    case 'objeCircle':
        clearObjectBackground(_obj);
    break;
    }
});
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Ramazan Zülkarneyn
  • 153
  • 1
  • 4
  • 14
  • 1
    To attach an event handler to a dynamically added element you need to use a delegated event handler. See the duplicate question for more information – Rory McCrossan Jul 04 '17 at 08:58
  • it was working when I first time try. Actualy it worked until 6 mounth. I dont know why it s not working now. I dont think so it s delegate event handler problem. Because I tried it s still same. Can you look this code.( I append element dynamicly and using jquery 1.9) @RoryMcCrossan – Ramazan Zülkarneyn Jul 04 '17 at 09:26
  • it solved thank you very much. @RoryMcCrossan – Ramazan Zülkarneyn Jul 04 '17 at 11:03

0 Answers0