Use $foo.msg( 'bar' ) rather than $foo.html( mw.message( 'bar' ).parse() )