Model view controller with JS

I have this custom popup function which accepts an object:


function popup(obj) {
 $('message').getElementsBySelector('strong')[0].update(messageObject.title);
 $('message').getElementsBySelector('span')[0].update(messageObject.message);
     
 if ($('message').visible())
   Effect.Fade('message', {duration: this.popupFadeTime});
 else
   Effect.Appear('message', {duration: this.popupFadeTime});
}

It’s used all over my site to popup different messages. For example:


popup({title: 'error has occurred', message: '<strong>required <i>field</i></strong>'});

Isn’t is wrong to put the HTML tags (view) in javascript (controller)? How do I separate view and controller when I need this generic popup function that can display any sort of HTML?