- Screen name: barbalex
barbalex's Profile
15 Posts
43 Responses
0
Followers
Show:
- Expanded view
- List view
Private Message
- I am trying to preserve the type of values written into a text input when saving them to the Database.So far I have set the type of the input to number (<input id="x" type="number" />) and chequed for $("#x").attr("type").When I parseInt the value, this is o.k. for Integers. But what to do with Floats?Simple. Test for typeof $("#x").(). If it is number, check if parseFloat($("#x").()) !== parseInt($("#x").()).Unfortunately typeof $("#x").() ALWAYS returns string.What am i missing?Cheers, Alex
- 12-Apr-2012 10:54 AM
- Forum: jQuery Mobile
Hi
I have trouble getting ajax to work. I want to get it working to speed things up and reduce calls to the database.
I have a document BeobEdit.html. It contains a page (data-role="page") with id="BeobEditPage" and a url, for example http://barbalex.iriscouch.com/evab/_design/evab/_show/BeobEdit/8c3c2f45fd2560a0f9b2fa9d2b001990.
When the user swipes right (or left) the same document is shown with the same page but a different url and data, for example http://barbalex.iriscouch.com/evab/_design/evab/_show/BeobEdit/5ce10d6c6376b4d4b9bd38f1f80159aa.
When I change pages using "window.open(url, target='_self')" it works perfectly.
When I use "$.mobile.changePage(url)" the first page works fine but if I swipe on then in the next pages lots of stuff does not work. Seems like event listeners dont work. They work after a refresh of the page.
I have put all the page specific code inside a $(":jqmData(role='page')").on("pageinit", function() callback inside the page div to make sure it is called every time the page is showed. I have also tried the pagebeforeshow event and others. I also use the same page headers on all pages.
I have tried a lot of stuff and read through many similar problems but I can't get my page to work using changepage.
Then I realized that while changing pages, both pages are the same .html file and the same data-role=page although a different url (calling different data from couchdb). Could this be the reason for my problems? I have tried using { allowSamePageTransition: 'true', reloadPage: 'true' } in changepage but that does not solve the problem.
I am not sure what the docs mean with same page. Is it same .html file, same data-role=page or same url?
If you look at the links, please log in using user = z and password = z (the site uses window.open now, so it works).
I am using jQuery mobile 1.1.0 RC2. Had the same issues with prior versions.
I am also using mustache for templates (https://github.com/janl/mustache.js).
Does this maybe influence the behaviour?Thanks for any hints
Alex
- HiI am using many input element types in the same form.Unfortunately they are not all rendered aligned and they don't have the exact same width.Specifically:
- input elements are broader than radio, checkbox or select.
- radio and checkbox align slightly farther left than input
- select align slightly farther right than input
See attachment.How can I get them to exactly align and have the exact same width?Thanks for helpAlexAttachments- form.PNG
- Size: 43.79 KB Downloads: 1675
- HiThe docs say very prominently not to use "$(document).ready()" any more but to use "pageInit()" instead.So I am trying to change to pageInit() and also change from "window.open" to "pageChange".I understand that to do this all pages should have the same header that references all the sources needed by any of the pages.And I understand the page specific code has to be in the <div data-role="page"> element.So far hopefully so good.Here is my problem: What is the correct call for pageInit? I have tried all of these:
- $(document).ready(function(){
- $(document).delegate("#FeldEditPage", "pagecreate", function() {
- $(document).delegate("#FeldEditPage", "pagebeforecreate", function() {
- $(document).bind("pageInit", function(){
- $("#FeldEditPage").bind("pageInit", function(){
- jQuery("div:jqmData(role='page'):last").bind('pageInit', function() {
- plus variations using live instead of bind.
The first three work only on the first document - not after changePage was executed. They work perfectly when I use window.open istead of changePage.With the others no code is executed at all.Thanks in advance for help!Alex- HiI have implemented swiping. It works nicely.There is a little problem though: When a user marks a word mith the mouse, this provokes the swipe event. To provent this I am looking for a way to call the swipe event only if the user swipes a minimum of x pixels (maybe 150).Is this possible?Thanks for help.Alex
- HiOn my page I have sliders and also swipe events:- On the change event of the slider I save the value of the slider.- On the swipe event (bound to the content-div) the next page opens.My problem is that moving the slider also calls the swipe event.What happens is that the next page opens and the value of the slider is not saved.How can I prevent the swipe event from being called when a slider is moved?Help is much appreciated.Alex
- 30-Nov-2011 12:20 PM
- Forum: jQuery Mobile
Forms have a slightly darker background color than the rest of the page. See here: http://barbalex.iriscouch.com/evab/_design/evab/index.htmlWeird enough, this does not seem to happen on the demos.So far I haven't tweaked the css.Can anyone help?Here's the html I use on above page:- <body>
- <div data-role="page">
- <div data-role="header" data-backbtn="false">
- <h1>anmelden</h1>
- </div>
- <div data-role="content">
- <p style="text-align: center"><b>EvAB</b> = <b>E</b>rfassung <b>v</b>on <b>A</b>rt-<b>B</b>eobachtungen</p>
- <form id="LoginForm" action="#" method="get" autocomplete="on">
- <div data-role="fieldcontain">
- <label for="UserName">Name:</label>
- <input id="UserName" name="UserName" type="text" autofocus required/>
- </div>
- <div data-role="fieldcontain">
- <label for="Passwort">Passwort:</label>
- <input id="Passwort" name="Passwort" type="password" required/>
- </div>
- </form>
- <p style="text-align: center">Sie sehen nur die eigenen Beobachtungen. Darum brauchen Sie ein Konto.</p>
- <p style="text-align: center">Diese App ist in Entwicklung. Vorläufig können Sie gerne mit Name "z" und Passwort "z" anmelden und alles ausprobieren.<br>Ihre Daten werden aber vor der Veröffentlichung gelöscht!</p>
- <p style="text-align: center">Ich freue mich über Rückmeldungen: <a href="mailto:alex.barbalex@gmail.com">email senden</a></p>
- <p style="text-align: center"><a href="http://www.barbalex.ch/news/latest/evabmobile/">mehr Infos hier</a></p>
- </div>
- <div data-role="footer">
- <div data-role="navbar">
- <ul>
- <li><a href="#" id="SubmitButton" data-icon="check" class="ui-btn-active">anmelden</a></li>
- <li><a href="Signup.html" id="SignupButton" data-icon="plus" rel="external">Konto erstellen</a></li>
- </ul>
- </div><!-- /navbar -->
- </div><!-- /footer -->
- </div>
- </body>
- HiMy page includes some lists.It works very well on: Chrome, Firefox6, IE9.On IE8 the lists remain empty, see attachment. Seems like the content does not make it into the DOM.Log in using user z and password z - never mind mingling in the data, it is only a still incomplete development version.The listview is built up with this code:
- function refreshBeobListe(Pfad) {
- $("#beobachtungen").empty();
- $db.view("evab/BeobListe",
- {success: function(data) {
- var i;
- var anzBeob = 0;
- var beob;
- var ListItemContainer = "";
- for(i in data.rows) { //Beobachtungen zählen. Wenn noch keine: darauf hinweisen
- key = data.rows[i].key;
- if (key[0] == User) { //nur eigene Beobachtungen zählen!
- anzBeob = anzBeob + 1;
- }
- }
- //Im Titel der Seite die Anzahl Beobachtungen anzeigen
- var Titel2 = " Beobachtungen";
- if (anzBeob==1){
- Titel2 = " Beobachtung";
- }
- $("#BeobListePageHeader .BeobListePageTitel").text(anzBeob + Titel2);
- if (anzBeob == 0) {
- $("#beobachtungen").append("<li>Sie haben noch keine Beobachtung erfasst</li>");
- } else {
- data.rows.reverse(); //zuletzt erfasste sind zuoberst
- for(i in data.rows) //Liste aufbauen
- {
- beob = data.rows[i].value;
- key = data.rows[i].key;
- if (key[0] == User) { //nur eigene Beobachtungen anzeigen!
- var Datum = beob.zDatum;
- var Zeit = beob.zZeit;
- var ArtGruppe = beob.aArtGruppe;
- ImageLink = Pfad + "Artgruppenbilder/" + ArtGruppe + ".png";
- var ArtName = beob.aArtName;
- var externalPage = "_show/BeobEdit/" + beob._id;
- var listItem = "<li class=\"beob ui-li-has-thumb\" id=\"" + beob._id + "\">" +
- "<a href=\"" + externalPage + "\" rel=\"external\">" +
- "<img class=\"ui-li-thumb\" src=\"" + ImageLink + "\" />" +
- "<h3 class=\"aArtName\">" + ArtName + "<\/h3>" +
- "<p class=\"zZeit\">" + Datum + " " + Zeit + "<\/p>" +
- "<\/a> <\/li>";
- ListItemContainer = ListItemContainer + listItem;
- }
- }
- }
- ListItemContainer = ListItemContainer + "<\/ul>";
- $("#beobachtungen").append(ListItemContainer);
- $("#beobachtungen").listview();
- $("#beobachtungen").listview("refresh");
- }
- });
- }
I have added this in the header to make it work in IE7 and IE8 but it does not help:- <script type="text/javascript">
- //customize jQuery Mobile to let IE7+ in (Mobile IE)
- //run this script after jQuery loads, but before jQuery Mobile loads
- $(document).bind("mobileinit", function(){
- $.extend( $.mobile , {
- //extend gradeA qualifier to include IE7+
- gradeA: function(){
- //IE version check by James Padolsey, modified by jdalton - from http://gist.github.com/527683
- var ie = (function() {
- var v = 3, div = document.createElement('div'), a = div.all || [];
- while (div.innerHTML = '<!--[if gt IE '+(++v)+']><br><![endif]-->', a[0]);
- return v > 4 ? v : !v;
- }());
- //must either support media queries or be IE7+
- return $.support.mediaquery || (ie && ie >= 7);
- }
- });
- });
- </script>
Thanks for help!AlexAttachments- BeobListe.txt
- Size: 9.74 KB Downloads: 2226
- HiWhen I use beta 2 my select menus work like a charm, as they did with several previous versions.When I use the latest nightly, they stay blanc and show no data.When loading the page, document ready calls this code to refresh the select menus that get their data (in this case "aArtGruppe") from the show function:
- function refreshArtGruppe(aArtGruppe)
- {
- $("select#aArtGruppe").selectmenu();
- $("select#aArtGruppe").empty();
- var startoption = "<option value='" + aArtGruppe + "'>" + aArtGruppe + "</option>";
- $("select#aArtGruppe").append(startoption);
- $("select#aArtGruppe").val(aArtGruppe);
- $("select#aArtGruppe").selectmenu("refresh");
I've tried using create instead of refresh. But the code works well in beta 2 plus I am refreshing widgets that were there before (they are in the template), so I believe refresh is the right method.Thanks for Help!Alex- I know the forum is full of these problems. But I haven't found an answer that answers mine.I hav a checkboxradio like this:
- <div data-role="fieldcontain">
- <fieldset data-role="controlgroup">
- <legend>Typ der Meldung:</legend>
- <input type="radio" name="aMeldungTyp" id="Feldbeobachtung" value="Feldbeobachtung"/>
- <label for="Feldbeobachtung">Feldbeobachtung</label>
- <input type="radio" name="aMeldungTyp" id="Herbarbeleg" value="Herbarbeleg" />
- <label for="Herbarbeleg">Herbarbeleg</label>
- <input type="radio" name="aMeldungTyp" id="Literaturangabe" value="Literaturangabe" />
- <label for="Literaturangabe">Literaturangabe</label>
- </fieldset>
- </div>
- //aMeldungTyp managen
- $("input[name='aMeldungTyp']").checkboxradio();
- if ("{{aMeldungTyp}}"!=""){
- aMeldungTyp = "{{aMeldungTyp}}";
- } else {
- aMeldungTyp = "Feldbeobachtung";
- }
- $("input#{{aMeldungTyp}}").attr("checked",true).checkboxradio("refresh");
- $("input[name='aMeldungTyp']").change(function(){
- aMeldungTyp = $(this).attr("id");
- });
Later I save the data like this:- $("#SpeichernButton").tap(function(event) {
- var docId = "{{id}}";
- $db.openDoc(docId, {
- success: function(doc) {
- (saving done)
- if ($("[id='aArtNameBemerkungen']").val()!=""){
- doc.aArtNameBemerkungen = $("[id='aArtNameBemerkungen']").val();
- } else if (doc.aArtNameBemerkungen!=null){
- delete doc.aArtNameBemerkungen;
- }
- doc.aMeldungTyp = aMeldungTyp;
- (more saving done)
- $db.saveDoc(doc, {
- success: function(data) {
- MeldungEinzeilig("Art gespeichert");
- },
- error: function() {
- MeldungEinzeilig("Die Art konnte nicht gespeichert werden.");
- }
- });
- }
- });
- });
First this worked like a charm. And it does still work on a different page. After several test with data I suddenly keep getting this error: "uncaught exception: cannot call methods on checkboxradio prior to initialization; attempted to call method 'refresh'".I don't understand this: Am I not initializing it correctly with this line?:- $("input[name='aMeldungTyp']").checkboxradio();
Fiddling around with the same problem with other widgets too (selectboxes) I found out that it seems to matter, where in handleDocumentReady you initialize and maybe how often. Are there any rules, where this should happen and how often it may happen?I have also tried .page(). But then I really start getting into deep water... (lots of other issues).Help is much appreciated.Alex- 21-Jun-2011 05:07 PM
- Forum: jQuery Mobile
My site (http://barbalex.couchone.com/evab-ch_barbalex_evab/_design/evab/index.html) works well with 1a4.1. With 1 beta 1 when it loads the appended page I get the mentioned error and the page remains white.Is there something I can do about it or is this a bug?The page is loaded with this code:- function refreshBeobListe()
- {
- $("#beobachtungen").empty();
- $db.view("evab/BeobListe",
- {success: function(data) {
- var i;
- var anzBeob = 0;
- var user;
- var beob;
- var zDatum;
- var zZeit;
- var bArtName;
- var externalPage;
- var listItem;
- var ListItemContainer = "";
- var UserZeit;
- for(i in data.rows) { //Beobachtungen zählen. Wenn noch keine: darauf hinweisen
- key = data.rows[i].key;
- User = userCtx.name;
- if (key[0] == User) { //nur eigene Beobachtungen zählen!
- anzBeob = anzBeob + 1;
- }
- }
- //$("#BeobListeHeader").text(anzBeob + " Beobachtungen"); //Header soll anzeigen, wieviele Beobachtungen erfasst wurden. Breaks jquery mobile style!
- if (anzBeob == 0) {
- $("#beobachtungen").append("<li>Sie haben noch keine Beobachtung erfasst</li>");
- } else {
- data.rows.reverse(); //zuletzt erfasste sind zuoberst
- for(i in data.rows) //Liste aufbauen
- {
- beob = data.rows[i].value;
- key = data.rows[i].key;
- User = userCtx.name;
- if (key[0] == User) { //nur eigene Beobachtungen anzeigen!
- zDatum = beob.zDatum;
- zZeit = beob.zZeit;
- bArtGruppe = beob.bArtGruppe;
- ImageLink = "Artgruppenbilder/" + bArtGruppe + ".png";
- bArtName = beob.bArtName;
- externalPage = "_show/BeobEdit/" + beob._id;
- listItem = "<li class=\"beob ui-li-has-thumb\" id=\"" + beob._id + "\">" +
- "<a href=\"" + externalPage + "\" rel=\"external\">" +
- "<img class=\"ui-li-thumb\" src=\"" + ImageLink + "\" />" +
- "<h3 class=\"bArtName\">" + bArtName + "<\/h3>" +
- "<p class=\"zZeit\">" + zDatum + " " + zZeit + "<\/p>" +
- "<\/a> <\/li>";
- ListItemContainer = ListItemContainer + listItem;
- }
- }
- }
- ListItemContainer = ListItemContainer + "<\/ul>";
- $("#beobachtungen").append(ListItemContainer);
- $("#beobachtungen").listview("refresh");
- }
- });
- 02-Mar-2011 10:11 PM
- Forum: jQuery Mobile
HiI have a listview where every li-element has an href with an id:- $.getJSON("Projektliste.php?callback=?", function(data) {
- $.each(data, function(key, value) {
- $("<li><a href='Projekt.html?id=" + value.id +"' rel='external' id=" + value.id + ">" + value.PrName + "</a><span class='ui-li-count'>" + value.AnzBeob + "</span></li>").appendTo("#Projektlisteneintraege");
- });
- $("#Projektlisteneintraege").listview("refresh");
- });
I try to open a menu when the user tapholds a list-item:- $('div').bind('taphold', function(event){
- var PrId = $(this).attr('id');
- alert("Die ID lautet: " + PrId);
- $.mobile.changePage("Projektliste_menu.html?id=" + PrId);
- });
I want to pass an id of the list-item that was tapheld. With this, it is possible to alter or delete list-items (and their data) in the menu.The problem is: although every list-item has "id=" with a value, $(this).attr('id') does not fetch it.This puzzles me, because I know that every list-item has a value in the id. And on another page I use the .change event which uses $(this).attr('id') too and that works perfectly:- $("input").change(function() {
- var Feldname = $(this).attr("id");
Here's the page: http://evab.barbalex.ch/Help is very much appreciated!- HiIn many apps tapholding an item opens a popup menu. I need this functionality too.So far I could not find out how to do this in jquery mobile.This is my state of knowledge:
$('.aBunchOfTapholds').bind('taphold', function(e){
var elem = $(this); //get's tapped object
// now open a popup menu. How?
});
I've seen dialogs. But it seems that they always fill the width of the page.Is it possible to set the width of a dialog?I get data with this:
$.getJSON("Personen.php", function(data) {
$.each(data, function(key, value) {
$("<option value='" + key + "'>" + value.Person + "</option>").appendTo("#projekt_autor");
});
});
and append it to a select menu:
<div data-role="fieldcontain">
<label for="projekt_autor" class="select">Autor:</label>
<select name="projekt_autor" id="projekt_autor">
<option>Autor wählen...</option>
</select>
</div>
Firebug shows the data to be in the page:
<label for="projekt_autor" class="select ui-select">Autor:</label>
<div class="ui-select">
<a class="ui-btn ui-btn-icon-right ui-btn-corner-all ui-shadow ui-btn-up-c" data-theme="c" aria-haspopup="true" role="button" href="#">
<span class="ui-btn-inner ui-btn-corner-all">
<span class="ui-btn-text">Autor wählen...</span>
<span class="ui-icon ui-icon-arrow-d ui-icon-shadow"></span></span></a>
<select tabindex="-1" name="projekt_autor" id="projekt_autor">
<option>Autor wählen...</option>
<option value="0">Affolter Theo, -</option>
<option value="1">AGEO -, -</option>
<option value="2">BACHMANN P., -</option>
etc.
</select></div>
But when I click the select menu, only the null option is shown (<option>Autor wählen...</option>).
How can I get all the data to show?
Here's the page: http://evab.barbalex.ch/Projekt.html
Very grateful for help!here's the script: Projekt.txt
Attachments- Projekt.txt
- Size: 8.8 KB Downloads: 2233
- I get data like this:
$.getJSON("Projektliste.php", function(data) {
$.each(data, function(key, value) {
$("<li><a href='Projekt.html' rel='external' id=" + key + ">" + value.PrName + "</a></li>").appendTo("#Projektlisteneintraege");
});
});
and append it to this listview: <ul data-role='listview' data-theme='g' id="Projektlisteneintraege"></ul>
The resulting page (http://evab.barbalex.ch) shows the data but it is not styled.
Firebug shows no errors.
How can I get jquery to style the listview?
Thanks for help!- «Prev
- Next »
Moderate user : barbalex
© 2013 jQuery Foundation
Sponsored by and others.

