Vue ProgressBar - Handle the Value Change Event
To process a new ProgressBar value, you need to handle the value change event. If the handling function is not going to be changed during the lifetime of the UI component, assign it to the onValueChanged property when you configure the UI component.
jQuery
JavaScript
$(function() { $("#progressBarContainer").dxProgressBar({ onValueChanged: function (e) { const previousValue = e.previousValue; const newValue = e.value; // Event handling commands go here } }); });
Angular
HTML
TypeScript
<dx-progress-bar [(value)]="value" (onValueChanged)="handleValueChange($event)"> </dx-progress-bar>
import { DxProgressBarModule } from "devextreme-angular"; // ... export class AppComponent { value = 49; handleValueChange (e) { const previousValue = e.previousValue; const newValue = e.value; // Event handling commands go here }; } @NgModule({ imports: [ // ... DxProgressBarModule ], // ... })
Vue
<template> <DxProgressBar v-model:value="value" @value-changed="handleValueChange" /> </template> <script> import 'devextreme/dist/css/dx.light.css'; import { DxProgressBar } from 'devextreme-vue/progress-bar'; export default { components: { DxProgressBar }, data() { return { value: 49 }; }, methods: { handleValueChange(e) { const previousValue = e.previousValue; const newValue = e.value; // Event handling commands go here } } } </script>
React
import React from 'react'; import 'devextreme/dist/css/dx.light.css'; import { ProgressBar } from 'devextreme-react/progress-bar'; class App extends React.Component { constructor(props) { super(props); this.state = { value: 49 }; this.handleValueChange = this.handleValueChange.bind(this); } handleValueChange(e) { const previousValue = e.previousValue; const newValue = e.value; // Event handling commands go here this.setState({ value: newValue }); } render() { return ( <ProgressBar value={this.state.value} onValueChanged={this.handleValueChange} /> ); } } export default App;
jQuery
If you are going to change event handlers at runtime, or if you need to attach several handlers to the value change event, subscribe to this event using the on(eventName, eventHandler) method.
JavaScript
const valueChangedHandler1 = function (e) { const previousValue = e.previousValue; const newValue = e.value; // First handler of the "valueChanged" event }; const valueChangedHandler2 = function (e) { const previousValue = e.previousValue; const newValue = e.value; // Second handler of the "valueChanged" event }; $("#progressBarContainer").dxProgressBar("instance") .on("valueChanged", valueChangedHandler1) .on("valueChanged", valueChangedHandler2);
See Also
Feel free to share topic-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.