1

2 days back when we enabled locker service document.getElementById('someid') was working. All of a sudden it stopped working and now gives undefined. i can see the div whose property i need to modify from browser F12. Please help.

3
  • 1
    I assume this is with LockerService activated based on the tags. Does the code work with LockerService off? Do you have any example code to look at? In general document.getElementById is functional, but there may be corner cases we missed. Jun 22, 2016 at 17:21
  • Hi Trevor, Yes the code works fine when locker service is off, when locker service is on, the line document.getElementById('maindatascreen').style.setProperty('display', 'none'); does not work. when i check document.getElementById('maindatascreen') in console log, it gives undefined. Jun 28, 2016 at 10:50
  • There are several examples of getElementById working inside LockerService. If you have in markup: <div id="maindatascreen"/> then document.getElementById("maindatascreen") will return that element. If you edit your question and include your markup I can help debug it. Jun 28, 2016 at 22:17

1 Answer 1

2

Try doing the same in the afterRender function in the renderer file.

({
afterRender: function(component, helper) {
    this.superAfterRender();
    //YOUR CODE
}

})

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .