03-23-2011 02:46 AM
I have to generate the contents of a dialog box on the fly (as I need to query the database for info first and then populate the dialog with it), but my problem is that the dialog box is only styled the first time it comes up. In the example below, (if you don't mind building and running on your sim), you click on the "New Dialog" at the top right, take a look at the dialog, it is styled by jQueryMobile which is good. Cancel out of it, and then click on the "New Dialog" button again and you'll see that the dialog is not styled at all. I'm guessing that something is being cached somewhere, any ideas? or workarounds?
03-26-2011 06:42 PM
Actually, this is happening to me even if it is not a dialog. I can't believe no one out there is not generating sub pages/dialogs on the fly and not running into this issue. Anyone?
03-26-2011 09:24 PM
I wrote a tutorial on this a while back:
give me some kudo's if it helps you out
and look at all the functionality including the function call from clicking the button in dialog
it removes the dialogs instance so you can recreate it again
03-27-2011 12:03 AM
I had seen your post, great stuff BTW, but I'm not seeing what you mentioned about removing the dialogs instance so that it can be recreated again...can you be a bit more specific?
thanks for your help
03-27-2011 12:49 AM
at the end of the function.
if this doesn't work you can also search the dom for the dialog as well.
03-27-2011 03:06 AM
Is not working for me. I think the $('[data-url=addLabel]').dialog('close'); is not really doing anything. I know it's getting called, but it doesn't close the dialog.
It could be that I have the bad reference, but I wrapped the dialog in a <div id='yy' data-url='addLabel'>, but nothing.
Do you have this code working fine on PlayBook?
It seems that on PB, if you have <A HREF="#addLabel"...> and don't have at least a blank <div id='addLabel'></div> and then generate it in the function of the onclick, I get "Error loading page"...
you have to have the blank div...but even so, it is not working for me ...darn...
03-27-2011 06:25 PM
have you tried the example code i gave?
you dont need to have an empty div, but the href needs to have dialog set in the data-rel etc..
give my example code a try, as well you should probably make sure you apply the fix i posted as well. just look at my posts there is one about fixing jquery mobile etc..
but yes this works perfectly on both the older vm and on the new vm
03-27-2011 08:06 PM
I think I've narrowed down the problem. If I call your code as the first thing in the function call, then it works fine. The problem is that before I bring up the dialog, I have to get data from the database, so I pick up the info from the database that I need to present first, then write out the <div>. When I do this, it doesn't work, it just hangs with "Loading" and i can see an error about "GET addLabel" in FireBug.
This is using your mod BTW. Any idea? Maybe I can write something like "loading" to the div first in the first function before getting the data from the database, and then write out the real info? I'll give that a shot, let me know if you have any other ideas.