JS work for dialog