onclick Example

Clicking on things is very common on web sites. This example shows how to bind a function to the click handler of a button.

<div id="app"> <p data-model="message"></p> <button onclick="changeMessage">Make a change</button> </div>
import {rjsf} from '../rjsf.js' (function() { const appElement = document.getElementById('app'); const app = new rjsf(appElement); const viewmodel = { functions: { changeMessage: function(e) { e.preventDefault(); const v = this; v.data.message = 'Now this message is.'; setTimeout(() => v.data.message = 'This message is here.', 1000); } }, data: { message: 'This message is here.', } }; app.init(viewmodel); })();

Back to example index