How to use the ractive.prototype function in ractive

To help you get started, we’ve selected a few ractive examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ractive-foundation / ractive-foundation / dist / ractivef-cjs.js View on Github external
initInstance: function (container) {

		// Have we mixed in extensions to all instances yet?
		if (!Ractive.prototype.findAllChildComponents) {
			_.mixin(Ractive.prototype, RactiveF.mixins);
		}

		var instance = new Ractive({
			el: container,
			template: Ractive.parse(container.innerHTML),
			components: RactiveF.components,
			onrender: function () {
				this.el.classList.remove('hide');
				this.el.classList.add('initialize');
			}
		});

		instance.on('*.*', RactiveF.genericEventHandler);

		instance.set('dataModel', '{{dataModel}}');
github ractive-foundation / ractive-foundation / dist / ractivef-cjs.js View on Github external
initInstance: function (container) {

		// Have we mixed in extensions to all instances yet?
		if (!Ractive.prototype.findAllChildComponents) {
			_.mixin(Ractive.prototype, RactiveF.mixins);
		}

		var instance = new Ractive({
			el: container,
			template: Ractive.parse(container.innerHTML),
			components: RactiveF.components,
			onrender: function () {
				this.el.classList.remove('hide');
				this.el.classList.add('initialize');
			}
		});

		instance.on('*.*', RactiveF.genericEventHandler);

		instance.set('dataModel', '{{dataModel}}');
github kogg / hovercards / extension / template_loading / index.js View on Github external
var $       = require('jquery');
var _       = require('underscore');
var async   = require('async');
var urls    = require('../../shared/urls');
var Ractive = require('ractive');

var analytics      = require('../analytics');
var authentication = require('../authentication');
var config         = require('../config');
var service        = require('../service');
require('../common/mixins');

Ractive.DEBUG = process.env.NODE_ENV !== 'production';

Ractive.prototype.observeUntil = function(keypath, handler, options) {
	if (this.get(keypath)) {
		handler(this.get(keypath));
		return { cancel: _.noop };
	}
	return this.observeOnce(keypath, handler, options);
};

Ractive.prototype.service = function(keypath, identity, handler) {
	var ractive = this;
	var val     = ractive.get(keypath);
	if (val && val.loaded) {
		return (handler || _.noop)(null, val);
	}
	ractive.set(keypath + '.loading', true);
	ractive.set(keypath + '.loaded', false);
	service(identity || val, function try_service(err, data) {
github kogg / hovercards / extension / template_loading / index.js View on Github external
var authentication = require('../authentication');
var config         = require('../config');
var service        = require('../service');
require('../common/mixins');

Ractive.DEBUG = process.env.NODE_ENV !== 'production';

Ractive.prototype.observeUntil = function(keypath, handler, options) {
	if (this.get(keypath)) {
		handler(this.get(keypath));
		return { cancel: _.noop };
	}
	return this.observeOnce(keypath, handler, options);
};

Ractive.prototype.service = function(keypath, identity, handler) {
	var ractive = this;
	var val     = ractive.get(keypath);
	if (val && val.loaded) {
		return (handler || _.noop)(null, val);
	}
	ractive.set(keypath + '.loading', true);
	ractive.set(keypath + '.loaded', false);
	service(identity || val, function try_service(err, data) {
		if (err) {
			ractive.set(keypath + '.err', err);
			ractive.set(keypath + '.loaded', true);
			ractive.set(keypath + '.loading', false);
			if (_.contains([401, 429], err.status)) {
				var do_it = function() {
					ractive.set(keypath + '.err.authenticate', function authenticate() {
						ractive.set(keypath + '.err.authenticate', _.noop);