Inside Buttons
You can also add buttons to fields.
Buttons screenshot

Properties

Property
Default
Accepted values
Description
classes
none
String
CSS classes for the button
label
none
String
Caption of the button
onclick
none
Function(model, field)
Triggered when click on the button
type
"button"
String
The HTML "type" attribute for the button, defaults to "button"

Example

The below example uses two buttons to read the location of the user and clear the location value.
1
{
2
type: "input",
3
inputType: "text",
4
label: "Location",
5
model: "address.geo",
6
buttons: [
7
{
8
classes: "btn-location",
9
label: "Current location",
10
onclick: function(model) {
11
if (navigator.geolocation) {
12
navigator.geolocation.getCurrentPosition(function(pos) {
13
model.address.geo = {
14
lat: pos.coords.latitude.toFixed(5),
15
lng: pos.coords.longitude.toFixed(5)
16
};
17
});
18
} else {
19
alert("Geolocation is not supported by this browser.");
20
}
21
}
22
},
23
{
24
classes: "btn-clear",
25
label: "Clear",
26
type: "reset"
27
onclick: function(model, field) {
28
model.address.geo = {
29
lat: 0,
30
lng: 0
31
};
32
}
33
}
34
]
35
}
Copied!
Copy link