Updating Inputs From Server

  1. Define the setValue method.
setValue: function(el, value) {
  $(el).val(value);
}
  1. Define the receiveMessage method.
receiveMessage: function(el, data) {
  console.log(data);
  if (data.hasOwnProperty('value')) {
    this.setValue(el, data.value);
  }
  // other parameters to update...
}

Where:

  • el is the DOM element.
  • value represents the new value.
  • data are received from R as JS object

It is good practice to add a data.hasOwnProperty check to avoid running code if the specified property does not exist.