Skip to content

Instantly share code, notes, and snippets.

var Player = Backbone.Model.extend({
defaults: {
"name": "James",
"kit": 10
}
});
var james = new Player();
james.on('change:kit', function(model) {
console.log("my new number is " + model.get('kit'));
@vikingmute
vikingmute / gist:a61ef9676219be37a401
Created July 9, 2014 08:48
temai-biz html file prototype
<!-- target:planForm -->
<div class="plan-form">
<h4>输入推广计划名称</h4>
<input data-ui="id:PlanName;type:TextBox;width:250" placeholder="计划名称">
<label data-ui="id:PlanNameHint;type:Label"></label>
<label data-ui="id:PlanNameValidity;type:Validity"></label>
<p>
<span data-ui="id:CreateBtn;type:Button">确定</span>
<span data-ui="id:CancelBtn;type:Button">取消</span>
@vikingmute
vikingmute / gist:1ebd9ce493859c311821
Last active August 29, 2015 14:02
temai-biz view template
/**
* @file 新建的View类模板
* @author zhangxuan06
*/
define(function (require) {
require('er/tpl!./form.tpl.html');
var langPlan = require('biz/lang/plan');
@vikingmute
vikingmute / gist:b61f93f3d9eab59f38d9
Last active August 29, 2015 14:02
temai-biz template - model (由于是表单类型 所以没有绑定datasrouce)
/**
* @file 计划新建或编辑的Model
* @author zhangxuan06
*/
define(function (require) {
var Model = require('er/Model');
var util = require('er/util');
var url = require('biz/url');
@vikingmute
vikingmute / gist:eb7b870255b8bde15079
Created June 25, 2014 03:20
temai-biz action template - form类型
/**
* @file 计划新建或编辑的Action
* @author zhangxuan06
*/
define(function (require) {
var Action = require('er/Action');
/**
* 新建计划Action的构造函数
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
</html>
<ul class="mp-hotsale-list" id="anti-encrypt-hotsale">
{%foreach from=$data.list.areaD key=key item=item%}
<li data-gap="{%$item.etime - $data.common_info.timestamp%}" class="mp-hotsale-item
{%if ($key+1) eq $data.list.areaD|@count %} mp-hotsale-noborder {%/if%}">
<h3>{%$item.title%}</h3>
<div class="mp-hot-brand">
<img src="{%$item.brandlogo%}" alt="{%$item.title%}"/>
</div>
<div class="mp-hotsale-info">
<div class="mp-hotsale-text">
import os,sys
dirname = sys.argv[1]
totalCount = 0;
cDir = os.getcwd()
#allowd file extsions, .js, .css ...
extDir = ['.js', '.less', '.tpl', '.html']
#dir avoided to be checked
avoidDir = ['index/tpl', 'index/js']
@vikingmute
vikingmute / gist:10621921
Created April 14, 2014 06:42
闭包,传入函数,匿名函数 in javascript
//inspired by http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/001386819873910807d8c322ca74d269c9f80f747330a52000
//python version on the way
//a javascript clousure sample
function testSum() {
var argsArr = Array.prototype.slice.call(arguments);
function sum() {
//clousure can get the acess to outer args and private variable
var sumNum = 0;
for(var i =0, len = argsArr.length; i < len; i++){