But shouldn't it be someting like
Sorry for my ignorance. But in your examples you refer to $(modal) in my usual way there is no reference to Modal or whatsoever. I am a bit confused.
Edit: This is how I declare formMessages:
var formMessages = $('#form-messages');
Should that be something like:
var formMessages = $(modal'#form-messages');