js: add 'isValid' callback
js: clear form when form is hidden
js: improve sample
add 'onDestroyed' callback