These are chat archives for AxisCommunications/locomote-video-player

27th
Nov 2014
Gaétan Collaud
@gaetancollaud
Nov 27 2014 10:47
Hi, sorry I had to go the last time.
Now I check if the element exists and I remove only the selected child and not all of them like I did previously.
Let me now if your pleased with this version or if you need something else
Alexander Olsson
@noseglid
Nov 27 2014 10:58
@gaetancollaud You don't handle the case where it doesn't exist in the DOM, but it was really added to the 'element' which was passed to the constructor. I think you need to save the DOM element itself rathern than the id.
This case:
``javascript var el = document.createElement('div'); var locomote = new Locomote(el); // ... do a lot of stufflocomote`, but not attach it to DOM
locomote.destroy();
javascript var el = document.createElement('div');
var locomote = new Locomote(el); 
// ... do a lot of stufflocomote`, but not attach it to DOM
locomote.destroy();
better formatting :)
Gaétan Collaud
@gaetancollaud
Nov 27 2014 11:01
Isn't it enough to check if getElementById is null ?
Alexander Olsson
@noseglid
Nov 27 2014 11:01
Well, it doesn't destroy it if it null. It will remain attached to whatever element was passed to the constructor.
Gaétan Collaud
@gaetancollaud
Nov 27 2014 11:02
Hum yeah I see your point here
Alexander Olsson
@noseglid
Nov 27 2014 11:04
Wouldn't it be enough to just do this.e.parentNode.removeChild(object); and store object as the DOM element of the Object tag?
So.. constructer stores the DOM object and destroy does the removeChild part,
?