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

combine data source urls on alpaca library #578

Open pishguy opened 6 years ago

pishguy commented 6 years ago

in this below code i have to use unique urls to get necessary data form server, how can i combine this urls to get data from server with one url for example:

http://127.0.0.1:8000/content_categories

my alpaca library implementation is:

$("#content_categories").alpaca({
    "data": [],
    "schema": "http://127.0.0.1:8000/schema",
    "options": "http://127.0.0.1:8000/options",
    "postRender": function (control) {
        $("#multiselect").parent().find("input[type=checkbox]").uniform();
    }
});

and server implementation to send result:

Route::get('/schema', function () {
    echo json_encode(
        ["type" => 'array', 
            "items" => 
                ["type" => "string", 
                    "enum" => ["salam", "ma"], 
                    "minItems" => 1, 
                    "maxItems" => 20
                ]
        ]);

});

Route::get('/options', function () {
    echo json_encode(
        ["helper" => "یک یا چند مورد انتخاب کنید", 
            "type" => "select", 
            "id" => "multiselect", 
            "focus" => false, 
            "size" => 1]
    );
});

for example:

Route::get('/content_categories', function () {
    echo json_encode([
            "schema" => ["type" => 'array',
                "items" =>
                    ["type" => "string",
                        "enum" => ["salam", "ma"],
                        "minItems" => 1,
                        "maxItems" => 20
                    ]
            ],
            "options" => ["helper" => "یک یا چند مورد انتخاب کنید",
                "type" => "select",
                "id" => "multiselect",
                "focus" => false,
                "size" => 1
            ]
        ]
    );
});