gitana / alpaca

Alpaca provides the easiest way to generate interactive HTML5 forms for web and mobile applications. It uses JSON Schema and simple Handlebars templates to generate great looking, dynamic user interfaces on top of Twitter Bootstrap, jQuery UI, jQuery Mobile and HTML5.
http://www.alpacajs.org
Other
1.29k stars 371 forks source link

typeahead error #179

Open deviant32 opened 9 years ago

deviant32 commented 9 years ago

typeahead field renders as read only and throws an error when using typeahead inside array item. In order to see the javascript error you have to add a second array item. The Error is on line 14075, null variable "d" which is a parameter for the datumTokenizer function. Browser: Chrome 39 Below is html to reproduce error:

<!DOCTYPE HTML>
<html>
<head>
    <title>Getting Started Sample</title>
    <meta charset="UTF-8">

    <link type="text/css" rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
    <link type="text/css" rel="stylesheet" href="http://code.cloudcms.com/alpaca/1.5.4/bootstrap/alpaca.min.css">

    <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.js"></script>
    <script type="text/javascript" src="http://code.cloudcms.com/alpaca/1.5.4/bootstrap/alpaca.min.js"></script>
    <script type="text/javascript" src="https://twitter.github.io/typeahead.js/releases/latest/typeahead.bundle.js"></script>

</head>
<body>

    <div class="container" style="margin-top:30px">
        <div class="row">
            <div class="col-md-12">
                <div id="field1"></div>
            </div>
        </div>
    </div>

<script type="text/javascript">
$(document).ready(function() {
    $("#field1").alpaca({
        "schema": {
            "type": "object",
            "properties": {
                "color": {
                    "type": "string",
                    "title": "Color"
                },
                "prescriptions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "medication": {
                      "title": "Medication",
                      "type": "string"
                    },
                    "dosage": {
                      "title": "Dosage",
                      "type": "string"
                    }
                  }
                }
              }               
            }
        },
        "options":{
            "fields":{
                "color":{
                    "typeahead": {
                        "datasets": {
                          "type": "local",
                          "source": ["Red", "Green", "Blue", "Orange"]
                        }
                    }
                },
                "prescriptions":{
                    "fields":{
                        "item":{
                            "fields":{
                                "medication":{
                                    "typeahead": {
                                        "datasets": {
                                          "type": "local",
                                          "source": ["Xanax", "Valium"]
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

    });
});
</script>

</body>

</html>
deviant32 commented 9 years ago

anyone have any ideas?