In a data input page, I encounter the need for various actions when specific data is entered. Currently, I handle data manipulation by sending back changes to the server and refreshing the screen. The application operates on an internal network for production management purposes, eliminating concerns about reloading time or file sizes for JavaScript libraries. Curious about exploring alternatives without reloading, I deliberated on using frameworks like Angular, React, and similar options. Most demonstrations display real-time updates as data is entered in one element, but this approach isn't particularly helpful here since only complete data inputs trigger updates. I considered implementing functionality where keystrokes trigger data acceptance on Enter, revert to initial state on Escape, and initiate different processes upon data acceptance. Vue.js caught my attention as an 'easy' to learn framework that could assist with this task. In the code snippet below, I attempt to create a component for a data entry block (consisting of a label and an input field) with the intention of passing parameters and updating when necessary. However, I face difficulties in implementation.
<ms-pages></ms-pages>
The component definition reads:
Vue.component('ms-pages', {
template: '<div class="form-group row">' +
'<label class="col-xs-4 col-form-label">Pages</label>' +
'<div class="col-xs-8">' +
'<input v-model="mspages" class="form-control" type="text">' +
'</div>' +
'</div>',
})
Encountering errors with v-model despite defining "mspages" in the Vue instance, I attempted to also define it within the component. Additionally, I experimented with defining the component in the Vue instance, yet struggled with the syntax. Contemplating whether the component should store the current data state seems redundant given that the data resides in the input element, prompting me to reevaluate this approach.
While my proficiency in JavaScript is limited, I pondered creating custom functions to listen to keystrokes on elements, although this may lead to lengthy and intricate code (a task I find easier in Python). Any assistance on resolving these challenges would be highly valued.