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>
In function handleDocumentReady() I am trying to manage it with this code:
- //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