How to use the mithril.p function in mithril

To help you get started, we’ve selected a few mithril 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 jsguy / misojs / mvc / user.js View on Github external
user: function(data){

			console.log('DATA', data);

			var me = this, i;
			me.name = m.p(data.name||"");
			me.email = m.p(data.email||"");
			//	Password is always empty first
			me.password = m.p(data.password||"");
			me.id = m.p(data._id||"");
			me.roles = [];

			rolesEnum.map(function(role, index){
				//	This will just be true/false - we need the string for saving...
				me.roles.push(m.p( (data.roles && data.roles.indexOf(role.name) !== -1)? role.name: false ));
			});

			//	Validate the model
			me.isValid = validate.bind(this, {
				name: {
					isRequired: "You must enter a name"
				},
				password: {
					isRequired: "You must enter a password"
				},
				email: {
github jsguy / misojs / mvc / user.js View on Github external
user: function(data){

			console.log('DATA', data);

			var me = this, i;
			me.name = m.p(data.name||"");
			me.email = m.p(data.email||"");
			//	Password is always empty first
			me.password = m.p(data.password||"");
			me.id = m.p(data._id||"");
			me.roles = [];

			rolesEnum.map(function(role, index){
				//	This will just be true/false - we need the string for saving...
				me.roles.push(m.p( (data.roles && data.roles.indexOf(role.name) !== -1)? role.name: false ));
			});

			//	Validate the model
			me.isValid = validate.bind(this, {
				name: {
					isRequired: "You must enter a name"
				},
				password: {
					isRequired: "You must enter a password"
				},
github jsguy / misojs / client / miso.js View on Github external
intro: function() {
			this.text = m.p("Create apps in a snap!");
			this.ani = m.p(0);
			this.demoImgSrc = m.p("img/misodemo.gif");
		}
	},
github jsguy / misojs / client / miso.js View on Github external
todo: function(data){
			data.done = data.done == "false"? false: data.done;
			this.text = data.text;
			this.done = m.p(data.done);
			this._id = data._id;
		}
	},
github jsguy / misojs / client / miso.js View on Github external
user: function(data){
			this.name = m.p(data.name||"");
			this.email = m.p(data.email||"");
			this.id = m.p(data._id||"");

			//	Validate the model
			this.isValid = validate.bind(this, {
				name: {
					isRequired: "You must enter a name"
				},
				email: {
					isRequired: "You must enter an email address",
					isEmail: "Must be a valid email address"
				}
			});

			return this;
		}
	},
github jsguy / misojs / mvc / home.js View on Github external
intro: function() {
			this.headerText = "<img src="/img/miso_logo_mfirst.png" class="miso-logo">";
			this.textByline = m.p("CREATE APPS IN A SNAP");
			this.scrollOffset = m.p();
		}
	},
github jsguy / misojs / client / miso.js View on Github external
user: function(data){
			this.name = m.p(data.name||"");
			this.email = m.p(data.email||"");
			this.id = m.p(data._id||"");

			//	Validate the model
			this.isValid = validate.bind(this, {
				name: {
					isRequired: "You must enter a name"
				},
				email: {
					isRequired: "You must enter an email address",
					isEmail: "Must be a valid email address"
				}
			});

			return this;
		}
github jsguy / misojs / client / miso.js View on Github external
var ctrl = this;

		//	View model
		ctrl.vm = {
			todoList: function(todos){
				this.todos = m.p(todos);
			},
			//	How many are left
			left: function(){
				var count = 0;
				ctrl.model.todos().map(function(todo) {
					count += todo.done() ? 0 : 1;
				});
				return count;
			},
			input: m.p("")
		};

		ctrl.addTodo = function(e){
			var value = ctrl.vm.input();
			if(value) {
				var newTodo = new self.models.todo({
					text: ctrl.vm.input(),
					done: false
				});
				ctrl.model.todos.push(newTodo);
				ctrl.vm.input("");
				api.save({ type: 'todo.index.todo', model: newTodo } ).then(function(res){
					newTodo._id = res.result;
				});
			}
			e.preventDefault();
github jsguy / misojs / client / miso.js View on Github external
userList: function(users){
				this.users = m.p(users);
			}
		};
github jsguy / misojs / client / miso.js View on Github external
user: function(data){
			this.name = m.p(data.name||"");
			this.email = m.p(data.email||"");
			this.id = m.p(data._id||"");

			//	Validate the model
			this.isValid = validate.bind(this, {
				name: {
					isRequired: "You must enter a name"
				},
				email: {
					isRequired: "You must enter an email address",
					isEmail: "Must be a valid email address"
				}
			});

			return this;
		}
	},