0

I have lots of code on my current page and due to its complexity, it is quite difficult to debug and go through each line of javascript to find the exact code that is causing the input field to be disabled. Is there a way we could inspect the element in either FF, Chrome or IE and debug the javascript code to find what code is setting the field to its disabled state?

I have tried various approaches like placing a breakpoint, adding a "debugger" but it does not show the exact function/code where the field is being set to its disabled state.

Cheers.

Neophile
  • 5,660
  • 14
  • 61
  • 107
  • Have you tried working with chrome dev tools? – AranS Aug 31 '16 at 13:51
  • Yep that's where I was trying out the "debugger" approach. However is there anything that would allow me to find what I'm looking for? – Neophile Aug 31 '16 at 13:52
  • I don't think so. Dev tools doesn't shows DOM elements's attributes/properties value "source", like it shows the styles sources. – DontVoteMeDown Aug 31 '16 at 13:52
  • An answer to a similar question: http://stackoverflow.com/a/29631624/2314737 suggests to use a `MutationObserver` – user2314737 Aug 31 '16 at 13:53
  • 1
    However, even with a complex code you can determine which functions/methods could change an element state. Can't you post your code ? – DontVoteMeDown Aug 31 '16 at 13:53
  • Have you tried the search in the devtools (e.g. for "disabled")? That might be the simplest thing if there are only a few hits. – Bergi Aug 31 '16 at 13:54
  • There are quite a few script components and there are various conditions on which the field gets enabled/disabled. Would be difficult to paste the whole thing. – Neophile Aug 31 '16 at 13:55
  • @Bergi: That was one of the first things I tried and I even commented out my code wherever I could find my code that was "disabling" it. However it still disabled the field. – Neophile Aug 31 '16 at 13:56
  • I tried your duplicate question scenario as well, Neither the subtree modification, node removal nor the attribute removal got fired when the field was enabled/disabled. – Neophile Aug 31 '16 at 13:58
  • In Chrome, you could try inspecting the input element, or in the Element inspector, choose the element you need to monitor. Right click the element markup and choose from the context menu "Break on" => "Attributes modifications". The inspector will break the execution in the next change in the input's attributes. – F.Igor Aug 31 '16 at 13:59
  • @FIgor: Tried that. The attributes modifications do not fire on load of the page. – Neophile Aug 31 '16 at 14:01

0 Answers0