1

2

3 用npm命令下载依赖,优点:不用去网上找链接,代码都一样

4.jQuery自动下载进node_modules文件下

npm install jquery --save  这句命令的意思是保存,使package.json文件与node_modules同步(save以后dependencies下才有jquery,有利于项目部署,此时若删掉node_modules文件,保留package.json,直接npm install会自动下载相关依赖)

5.把代码写成这种形式,避免直接写到window中(可能将window的属性覆盖)

;(function(){
'use strict'; })();

6.传统reset方法http://meyerweb.com/eric/tools/css/reset/index.html

现采用normalize方法https://necolas.github.io/normalize.css/(或http://www.bootcdn.cn/normalize/)

其命令为:npm install normalize.css

在html中引用normalize.css时应该放在第一位

7.原理框图如下

8.storejs插件

参考:https://www.awesomes.cn/repo/marcuswestin/store-js

适用于所有浏览器的本地存储,不使用 cookies 或者 flash。会根据浏览器的不同选择 localStorage, globalStorage, 和 userData 作为存储引擎。

store.js 公开了一个简单的接口来实现跨浏览器的本地存储。

// Store 'marcus' at 'username'
store.set('username', 'marcus') // Get 'username'
store.get('username') // Remove 'username'
store.remove('username') // Clear all keys
store.clear() // 存储一个对象字面量 - store.js 内部使用了 JSON.stringify
store.set('user', { name: 'marcus', likes: 'javascript' }) // 获取存储的对象 - store.js 内部使用了 JSON.parse
var user = store.get('user')
alert(user.name + ' likes ' + user.likes) // Get all stored values
store.getAll().user.name == 'marcus' // Loop over all stored values
store.forEach(function(key, val) {
console.log(key, '==', val)
})

在本项目中

    function refresh_task_list() {
store.set('task_list',task_list);
render_task_list();
}
function get(index) {
return store.get('task_list')[index];
}

9.datatimepicker插件

参考:http://www.jq22.com/jquery-info332

该插件可以精确到分钟

function render_task_detail(index) {
if(index===undefined||!task_list[index]) return;
var item =task_list[index];
var tpl=
'<form>'+
'<div class="content">'+
(item.content||'')+
'</div>'+
'<div class="input-item"><input style="display: none" type="text" name="content" value="'+item.content+'"></div>'+
'<div>'+
'<div class="desc input-item">'+
'<textarea name="desc">'+(item.desc||'')+'</textarea>'+
'</div>'+
'</div>'+
'<div class="remind input-item">'+
'<label>提醒时间</label>'+
'<input class="datetime" name="remind_date" type="text" value="'+(item.remind_date||'')+'">'+
'</div>'+
'<div input-item><button type="submit">更新</button></div>'+
'</form>'; /*清空task详情模板*/
$task_detail.html(null);
/*使用新模板*/
$task_detail.html(tpl);
$('.datetime').datetimepicker();
/*选中其中的form元素*/
$update_form=$task_detail.find('form');
$task_detail_content=$update_form.find('.content');
$task_detail_content_input=$update_form.find('[name=content]');
/*双击内容元素显示input,隐藏自己*/
$task_detail_content.on('dblclick',function () {
$task_detail_content_input.show();
$task_detail_content.hide();
}) $update_form.on('submit',function (e) {
e.preventDefault();
var data={};
/*获取表单中各个input的值*/
data.content=$(this).find('[name=content]').val();
data.desc=$(this).find('[name=desc]').val();
data.remind_date=$(this).find('[name=remind_date]').val();
update_task(index,data);
hide_task_detail();
})
}

项目中使用到了Deferred(延迟)对象,具体可以参考我的另一篇文章:http://www.cnblogs.com/yujihang/p/6875263.html

【jQuery】todolist的更多相关文章

  1. 【jQuery】使用JQ来编写面板的淡入淡出效果

    本文与上一篇的<[jQuery]使用JQ来编写最主要的淡入淡出效果>(点击打开链接)为姊妹篇. 但上一篇仅仅是对文本的基本控制,本篇则是对面板元素进行控制. 尽管功能上很类似,可是所用到的 ...

  2. 【jQuery】复选框的全选、反选,推断哪些复选框被选中

    本文与<[JavaScript]复选框的全选.反选.推断哪些复选框被选中>(点击打开链接)为姊妹篇,把里面内容再与jQuery框架中实现一次,相同做到例如以下的效果: 布局还是相同的布局, ...

  3. js【jquery】 - DOM操作

    1.修改元素样式 js方式: var div2 = document.getElementById("") div2.style.width = '200px'; div2.cla ...

  4. 【jQuery】 实用 js

    [jQuery] 实用 js 1. int 处理 parseInt(") // int 转换 isNaN(page) // 判断是否是int类型 2. string 处理 // C# str ...

  5. 【jQuery】 Ajax

    [jQuery] Ajax $.ajax({ type: "Post", // 发包方式 cache: false, // 是否缓存 contentType: "appl ...

  6. 【jQuery】 常用函数

    [jQuery] 常用函数 html() : 获取设置元素内的 html,包含标签 text() : 获取设置元素内的文本, 不包含标签 val() : 获取设置 value 值 attr() : 获 ...

  7. 【jQuery】 资料

    [jQuery] 资料 1. 选择器 http://www.w3school.com.cn/jquery/jquery_ref_selectors.asp 2. 事件 http://www.w3sch ...

  8. 【jQuery】 效果

    [jQuery] 效果 资料 http://www.w3school.com.cn/jquery/jquery_ref_effects.asp 1. 显示隐藏 hide(); 隐藏 show(): 显 ...

  9. 【jQuery】 选择器

    [jQuery] 选择器 资料: w3school  http://www.w3school.com.cn/jquery/jquery_ref_selectors.asp 1. 标签选择器 : $(& ...

随机推荐

  1. Golang报错mixture of field:value and value initializers

    Golang 在使用匿名成员初始化时,如果出现 mixture of field:value and value initializers 是因为初始化的方式不对,见代码: package main ...

  2. groovy实现循环、交换变量、多赋值、?.运算符

    /** * Created by Jxy on 2019/1/3 10:01 * 1.实现循环的方式 * 2.安全导航操作符---?. * 3.一次性赋值给多个变量 */ 0.upto(2){ pri ...

  3. 进度监视器--ProgressMonitorInputStream

    进度监视器--ProgressMonitorInputStream ProgressMonitorInputStream 可以创建一个进度监视器,以监视读取输入流的进度.如果需要一段时间,将会弹出 P ...

  4. Bootstrap框架和inconfont、font-awesome使用

    iconfont的使用:https://www.cnblogs.com/clschao/articles/10387580.html Bootstrap介绍 Bootstrap是Twitter开源的基 ...

  5. 收藏的几个关于php面向对象教程

    面向对象的分析方法是利用面向对象的信息建模概念,如实体.关系.属性等,同时运用封装.继承.多态等机制来构造模拟现实系统的方法,学会了面向对象思想,能够大大提高php编程开发效率!本篇文章php中文网将 ...

  6. 【MFC】转:在CHtmlView中判断页面加载完成

    在列出别人的代码前,记录下自己的,覆盖父类的OnNavigateComplete2函数即可. typedef struct _tagEventURL { CString strUrl; HANDLE ...

  7. npm 更新至最新版本

    有时npm版本低了,一些操作有问题,要更新成最新. 官网中:  https://www.npmjs.com/get-npm     先查看对应的 node 版本 和 npm版本 Check that ...

  8. LeetCode赛题----Find Left Most Element

    问题描述 Given a binary tree, find the left most element in the last row of the tree. Example 1: Input: ...

  9. Web Api ——创建WebAPI

    方法在Win10 + VS2017(MVC5)测试通过 1.建立 WebApi项目: 选择菜单 “文件->新建醒目->web ->ASP.NET Web 应用程序” 输入项目名称和位 ...

  10. Binary Tree Inorder/Preorder Traversal 返回中序和前序/遍历二叉树的元素集合

    给定一个二叉树,以集合方式返回其中序/先序方式遍历的所有元素. 有两种方法,一种是经典的中序/先序方式的经典递归方式,另一种可以结合栈来实现非递归 Given a binary tree, retur ...