This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var model = {}, // empty model object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// link ui to model | |
form.link(model); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// clone the data model | |
var item = $.extend({}, model) | |
$.tmpl("<li>${task}</li>", item).appendTo(list); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pull back the data | |
var todos = list.find("li").map(function () { | |
return $(this).tmplItem().data; | |
}).get(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div data-role="container" data-hidden="true" data-options='{"name":"James Hughes"}'></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("div").data("role") === "container"; | |
$("div").data("hidden") === true; | |
$("div").data("options").name === "James Hughes"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var user = { | |
username: 'jameshu', | |
fullName: 'James Hughes' | |
}; | |
$(user).bind("changeData", function( event, name, value ) { | |
console.log(name + " changed to " + value); | |
}); | |
$(user).data("username", "jameshu2"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@inherits System.Web.Mvc.WebViewPage<Models.Person> | |
@{ | |
View.Title = "Home Page"; | |
LayoutPage = "~/Views/Shared/_Layout.cshtml"; | |
} | |
<div> | |
@Html.ValidationSummary() | |
@{Html.EnableClientValidation();} | |
@using(Html.BeginForm()){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |