This is truly odd. I've got an index.html file that uses a pageshow event to register a button handler:
$("#mainPage").live("pageshow",function(event) {
console.log("pageshow for mainPage");
$("#submitButton").one("touchend",function(e) {
This is used to handle login logic. When I run my app, this works perfectly one time. I only return to this page when I logout. I can confirm that when I return that the pageshow log shows up. But the submit button handler isn't registered. I can even do
console.dir($("#submitButton"))
just to confirm it is still in the DOM, and it definitely is. But it is like the one() refuses to register the event. Btw, I tried one() because I thought maybe my on() was registering the event twice.
I've got what I think is a simple requirement. The first page of my JQM app is a login page. The second, and so on, are my 'real' pages. I'm trying to prevent the user from hitting the Back button so much they end up on the login page.
According to the docs, pagebeforechange can be used to prevent navigation to another page. I've been able to confirm this. No big surprise there. But when I prevent the navigation, the URL in the browser still changes. Hitting back again performs another back and the user is sent to the initial page.
Click to load page 2. Click back. Notice you DON'T go back visually, but the URL changes. Click back again and you are out of the site. Just view source on index.html for the code I'm using - you can see it at the bottom.
I've got a JQM page that does an Ajax call to get a list of classes. I take that data and render a dynamic list. Each LI links to
class.html?id=X
where X is a unique ID. The pageshow handler that page parses window.location.search (the query string). This works on the desktop. It works in PhoneGap on the Android emulator. But it fails on a real device (again, wrapped in PhoneGap). Any ideas?
I've got two questions about dynamic checkboxes. My page has a div with a controlgroup role and an empty fieldset.
<div data-role='fieldcontain' id="toFieldWrap" >
<fieldset data-role='controlgroup' id="toField">
</fieldset>
</div>
My code creates a legend and set of checkboxes and injects it into toField. I then ran:
$("input[type='checkbox']").checkboxradio();
That worked, but each checkbox was it's own unit - as seen in the screen shot here:
Obviously the red was added later. I was able to get around this by calling .page() on the fieldset:
$("#toFieldWrap").page();
That worked... kinda (see next issue), but where is .page() officially documented?
The next issue is that calling page added a bgcolor to the fieldset that stretched below the actual content. See below - and hopefully it isn't too subtle to see.
as a way to configure the text for the close button. But dialogs do not have text on the close button, instead it simply has a "X" icon you can click to close it. Now that does have a tooltip which says close, but as that is useless on a mobile device, what exactly is this feature used for?
The page linked with this code uses a back button in the header so folks can leave the page. But, when they go to other pages, they can't use the back button. So I figured - just listen for the pageremove event and remove the event listener.
In earlier builds of JQM, my site would have an index.html page that included jQuery+JQM. When I linked to other pages, I could simply use the div page wrapper and be done with it. Since the URL always included index.html, if you book marked so sub page, you still got a proper display.
Now that pushState is used to update the URL in the browser. I found that if I went to some sub page, bookmarked the url, and returned, I'd get an unstyled display. That kinda makes sense - but I'm wondering now if the "best practice" is to always include the full header? Actually I'm not sure I'd call it a "best practice" - it would be required.
I could probably test this quicker than I can write the question, but if page A has a link to page B and uses data-prefetch, and page B has N more links like that, will they also be prefetched? Or are they only loaded when B itself is actually rendered. I'm assuming so - but I want to be sure.
So, I've got an interesting problem. I want to manipulate a list on a page every time the page loads. If I use pageShow as my event listener, it's run BEFORE the page's controls are initialized and therefore will throw an error if I do something like listview('refresh'). If I use pageCreate, it works perfectly. But that's only run once.
So what's the best way then to handle updating controls every time the page is viewed, bur AFTER the initial creation?
This seems to work just fine. Within my page I'm going to have a listview that I need to manipulate. When I'm done, I know I need to refresh, so I added this so I wouldn't forget:
$("#favoritesList").listview('refresh');
However, when I do this, I get:
Uncaught cannot call methods on listview prior to initialization; attempted to call method 'refresh'
While it kind of makes sense - I don't get why the listview isn't initialized by the time pageshow is run.
Right now the data is hard coded while I test. My question is - how do I access the data values from within my page? My page uses a div with a specific ID and I added an event listener for it loading:
I've noticed that a form within a page loaded as a dialog seems to reload the animation. What I mean is - I get an ajax post, as expected, but it's like the dialog goes away and re-appears. Is there a way to disable that? I know I could simply write my own code to handle my form post, but I'm hoping there is a simple solution.
If you search for "e" you will get a lot of results. The Prev/Next buttons work fine, but what I'm playing around with is swipe left and right events. I thought it might be cool if you could paginate using swipe events. In my index2.cfm file I added the following simple code:
As you can see, I'm just logging now, not actually moving the user yet. Anyway, what's weird is that the URLs I'm picking up are being cached. If I swipe right I see the proper next url. But if I click the button to go to the next page and swipe right again, I'm seeing the same URL.
This worked fine. So I then added a button so I could test a swipe event over it. Unfortunately, the second I added the button (even with the event handler comment out), my tap events completely stopped working.
I've noticed that when doing a simple form post on a page that uses a "large" select (ie, a select that loads a new page to let you pick the item) that my form posts no longer work. I end up with a 404 error instead. This only happens if I make use of the large select. If I leave it alone I can post the form just fine.