refresh a header after adding it dynamically

refresh a header after adding it dynamically

there are several posts that mention similar problems, but i haven't been able to find anything that solves this. i'm dynamically adding a header to a page. how do i refresh it so that the jquery mobile styles are activated? as some other posts comment on, page() doesn't work. here's my code:

  1.  $(document).ready(function(){
  2. $('div[data-role*="page"]').each(function(i){
  3. if($(this).children('div[data-role*="header"]').length!=0){
  4. alert("has header");
  5. }
  6. else{
  7. $(this).prepend("<div data-role='header'><h1>Welcome</h1></div>");
  8. //need to refresh here
  9. }
  10. });
  11. });