Update Text in the Page

  • page

CanJS will update the page automatically when observable data changes. To make observable data, pass raw data to can.Map, can.List or can.compute like:

var data = new can.Map({message: "Hello World!"});

To change the message, use the attr() method of can.Map.

data.attr("message", "Goodbye World!")

When the button is clicked in the example below, the message is changed with data.attr().