0

I am working on an Enterprise app. I need to style certain pop-ups that are shown in application. I found that whenever a popup is shown following div is added to the body.

<div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ui-draggable ui-resizable" tabindex="-1" role="dialog" aria-describedby="ui-id-12" aria-labelledby="ui-id-13" style="position: absolute; height: auto; width: auto; top: 263px; left: 626px; display: none;">

The idea is to detect when this popup is added and then add classes to it as per my need. To accomplish that and for this I am using following code

    $(document).on('DOMNodeInserted',"div.ui-dialog", function(e){
        console.log("Dialog Div Added");
    });

But this is not working.

Please Help

Neel
  • 613
  • 4
  • 14
  • 32

2 Answers2

1

You could use the DOMSubtreeModified event. For example:

$(document).on('DOMSubtreeModified',function(){
  console.log("now there are " + $('a').length + " links on this page.");
})

Or

$(document).on('DOMAttrModified',function(){
  console.log("now there are " + $('a').length + " links on this page.");
})

Or

$(document).on('DOMNodeInserted',function(){
  console.log("now there are " + $('a').length + " links on this page.");
})

You can see more events to use here: http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-eventgroupings-mutationevents and see which one works better for you.

Igor Escobar
  • 1,047
  • 1
  • 12
  • 13
0

You are talking about dom mutation event handling. have a look at this: https://stackoverflow.com/a/4561975/2478038

Community
  • 1
  • 1
Novalis
  • 81
  • 6