0

I have just started using JQueryMobile and built a little app. This app has one page with a table that i build dynamically using javascript. This table is being built at the app load and each 10 seconds. After the table is build with all the rows and other stuff , i add it to a div (data-role=page).

On the first time i use $.mobile.changePage("#WantedPage") , it works fine and has the css design. But, if i stay one this page and the method of the dynamic build of the table is called it looses all of its design it had before.

I tried already to reload the page also after building this table but it still has the same problem.

Can anyone give me a direction with this issue? I will be glad to give more info if needed.

Edit:

Each td in the table has a button inside it and i noticed recently that before the re-build of the table with new button , it creates a div that has a span and button in it. and after the re-build , i have only a button in it.

FelProNet
  • 689
  • 2
  • 10
  • 25

1 Answers1

2

Just trigger this line after you add dynamic content:

$( ".selector" ).table( "rebuild" );

First time it works because you are adding it to other page. Secone page is not enhanced because it was never active before. As soon as you transit to it jQuery will enhance full page markup, including dynamically added table.

But, when page becomes active, if you add dynamic content, you will need to enhance it manually.

There's another function that can help you, but in this case trigger it on whole page:

$('#pageId').triggerWithin();

On there other hand, if you want to find more about this topic read another related answer.

Working example: http://jsfiddle.net/Gajotres/vds2U/85/

Community
  • 1
  • 1
Gajotres
  • 57,309
  • 16
  • 102
  • 130
  • Thanks a lot! The link "related answer" helped me and i am sure it will be usefull for me in the future. – FelProNet Jun 13 '14 at 13:07