fixes #4659 JS errors when you Edit a Container

Fixed the issue and pushed the code for review, please check it.