// Dialer container element
var dialerElement = document.querySelector("#kt_dialer_example_1");
// Create dialer object and initialize a new instance
var dialerObject = new KTDialer(dialerElement, {
min: 1000,
max: 50000,
step: 1000,
prefix: "$",
decimals: 2
});
The following are the Dialer's functionality methods for more control.
Name
Description
Static Methods
createInstances(DOMString selector)
Initializes Bootstrap Dialer instances by selector. Default value of selector is [data-kt-dialer="true"].
This method can be used to initialize dynamicly populated Bootstrap Dialer instances(e.g: after Ajax request).
KTDialer.createInstances();
getInstance(DOMElement element)
Get the Dialer instance created
var dialerElement = document.querySelector("#kt_dialer_example_1");
var dialerObject = KTDialer.getInstance(dialerElement);
Public Methods
KTDialer(DOMElement element, Object options)
Constructs a new instance of KTDialer class and initializes a Dialer control:
var dialerElement = document.querySelector("#kt_dialer_control");
var dialerObject = new KTDialer(dialerElement, options);
Remove data-kt-dialer="true" attribute to avoid lazy initializes.
For options object refer to above Options Reference section.
increase()
Increases the input value with the configured step value.
dialerObject.increase();
decrease()
Decreases the input value with the configured step value.
dialerObject.decrease();
setValue(Number value)
Sets a new value.
dialerObject.setValue(50);
getValue()
Gets current value.
var value = dialerObject.getValue();
setMinValue(Number value)
Sets a new min value.
dialerObject.setMinValue(50);
setMaxValue(Number value)
Sets a new max value.
dialerObject.setMaxValue(5.5);
update()
Updates current value with min and max values validation.
dialerObject.update();
getElement()
Returns the Dialer's attached DOM element.
var element = dialerObject.getElement();
destroy()
Removes the component instance from element.
dialerObject.destroy();
Events
Below are few events for hooking into the Dialer functionality.
Event Type
Description
kt.dialer.increase
This event fires before running the increase method
kt.dialer.increased
This event fires after running the increase method
kt.dialer.decrease
This event fires before running the decrease method
kt.dialer.decreased
This event fires before after the decrease method
kt.dialer.change
This event fires before running the increase or the decrease method
kt.dialer.changed
This event fires after running the increase or the decrease method
var dialerElement = document.querySelector("#kt_dialer_example_1");
var dialerObject = new KTDialer(dialerElement, { /* options */ });
dialerObject.on('kt.dialer.increase', function(){
// do something...
});