Skip to content

Instantly share code, notes, and snippets.

View kouphax's full-sized avatar

James Hughes kouphax

View GitHub Profile
var model = {}, // empty model object
// link ui to model
form.link(model);
// clone the data model
var item = $.extend({}, model)
$.tmpl("<li>${task}</li>", item).appendTo(list);
// pull back the data
var todos = list.find("li").map(function () {
return $(this).tmplItem().data;
}).get();
<div data-role="container" data-hidden="true" data-options='{"name":"James Hughes"}'></div>
$("div").data("role") === "container";
$("div").data("hidden") === true;
$("div").data("options").name === "James Hughes";
var user = {
username: 'jameshu',
fullName: 'James Hughes'
};
$(user).bind("changeData", function( event, name, value ) {
console.log(name + " changed to " + value);
});
$(user).data("username", "jameshu2");
jQuery.type(true) === 'boolean'
jQuery.type(3) === 'number'
jQuery.type('test') === 'string'
jQuery.type(function(){}) === 'function'
jQuery.type([]) === 'array'
jQuery.type(new Date()) === 'date'
jQuery.type(/test/) === 'regexp'
@inherits System.Web.Mvc.WebViewPage<Models.Person>
@{
View.Title = "Home Page";
LayoutPage = "~/Views/Shared/_Layout.cshtml";
}
<div>
@Html.ValidationSummary()
@{Html.EnableClientValidation();}
@using(Html.BeginForm()){
public class PasswordsMustMatchAttribute : ValidationAttribute
{
protected override ValidationResult IsValid(
object value, ValidationContext validationContext)
{
var model = validationContext.ObjectInstance as Person;
if (model.Password == model.PasswordConfirm)
{
return ValidationResult.Success;
}