dynamically populating div="role=page" from json

dynamically populating div="role=page" from json

I am trying to sort out with the folliowing issue.

I have a system in which the user selects a record to edit in a listview. this listview links to another In the   PageBeforechange  event,  (on the 1st call when toPage is a string) tehre is a json call to the server to get the data entry page definition. I use this data to build teh data entry form (header, content & footer) everything works and is rendered as I intended.  Then the user does what he/she needs to do, clik on the save button the data is send to the server and the display returns to the listview. 

If now the user repeats the same process a second time. Every thing works (everything is in place) also bar the header which is there but not rendered as a fixed header with a navbar as before. it is just a div, themed but not enhanced. 

I have checked multiple times the page div is emptied before generating header, footer & content divs, every button on the form works, with the correct script called etc .... just this rendering issue which drives me potty. 

Any hint on where to start looking would be of a great help

thanks in advance