You need to add the js using ``#attached``, otherwise it won't work on validation error.