new Ractive({...})
Initialisation
Ractive instances are created using standard javascript instantiation with the new
keyword:
var ractive = new Ractive();
There are no required options, however you'll usually want to specify these base options:
var ractive = new Ractive({
el: '#container',
template: '#template',
data: data
});
The full list of initialisation options is covered here.
Initialising Ractive.extend
Ractive offers an extend method for standard javascript prototypical inheritance:
var MyRactive = Ractive.extend({
template: '#mytemplate'
});
The same initialisation options can be supplied to the extend method, plus some additional options.
These are instantiated in exactly the same way as above, supplying any additional options:
var ractive = new MyRactive({
el: '#container',
data: data
});
See Ractive.extend() for more details.
Initialisation without new
You can also create a new Ractive instance by calling Ractive as a function. It will handle creating a new object and return it from the call.
var ractive = Ractive({
el: '#container',
template: '#template',
data: data
});