<html><head><scriptsrc="underscore.js">script><scriptsrc="jquery.js">script><scriptsrc="backbone.js">script>head><body><pid=header1>header1p><pid=header2>header2p><scripttype="text/javascript">var ToDoItemView = Backbone.View.extend({
tagName:'p',
id:'myId', //p标签的id
render:function(){this.$el.html('This is a new span.');
//this.$el.html(''+this.model.get('title')+'');returnthis;
}
});
var view1 = new ToDoItemView();
var view2 = new ToDoItemView();
view1.render().$el.appendTo($('body'));
view2.render().$el.appendTo($('body'));
view1.remove();
script>body>html>
model1.on('change',function(){
console.log('change event is triggered by set function()');
//this.changed对象,知道Model的哪些属性发生了变化
//console.log(this.changed);
//if(this.hasChanged('title')){
console.log('title attribute is changed.');
}else{
console.log('title attribute is not changed.');
}
});
<html><head><scriptsrc="underscore.js">script><scriptsrc="jquery.js">script><scriptsrc="backbone.js">script>head><body><scripttype="text/javascript">var TodoItem = Backbone.Model.extend({});
var model1 = new TodoItem({
'title':'title1',
'description':'description1'
});
model1.on('change',function(){
console.log('change event is triggered by set function()');
//this.changed对象,知道Model的哪些属性发生了变化
console.log(this.changed);
});
script>body>html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
浏览器测试: thi.changed对象:输出变化了的属性。
监听某个属性的变化:
//内置事件:只监听title属性的变化
model1.on('change:title',function(){
console.log('attribute is changed.');
if(this.hasChanged('title')){
console.log('title attribute is changed.');
}else{
console.log('title attribute is not changed.');
}
});
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
1.5.Model对象之间的监听:listenTo()
用途:一个Model对象监听另外一个Model对象的事件【内置事件或自定义事件】
<html><head><scriptsrc="underscore.js">script><scriptsrc="jquery.js">script><scriptsrc="backbone.js">script>head><body><scripttype="text/javascript">var TodoItem = Backbone.Model.extend({});
var model1 = new TodoItem({
'title':'title1',
'description':'description1'
});
model1.on('change',function(){if(this.hasChanged('title')){
console.log('title attribute is changed.');
}else{
console.log('title attribute is not changed.');
}
});
model1.on('lala',function(){
console.log('lala');
});
//对象之间的监听var model2 = new TodoItem({
});
model2.listenTo(model1,'change',function(){
console.log('listen to modle1 change event!');
console.log(this); //这里的this是model2
});
model2.listenTo(model1,'lala',function(){
console.log('listen to modle1 lala custom event!');
console.log(this); //这里的this是model2
});
script>body>html><scripttype="text/javascript">script>
<html><head><scriptsrc="underscore.js">script><scriptsrc="jquery.js">script><scriptsrc="backbone.js">script>head><body><p>this is view event page p><scripttype="text/javascript">var BookModel = Backbone.Model.extend();
var book1 = new BookModel({
'title':'book1',
'description':'description1'
});
var BookView = Backbone.View.extend();
var bookView1 = new BookView();
//View监听Model的参数变化
bookView1.listenTo(book1, 'change', function(){
console.log('bookView1 has received the change from book1.');
});
script>body>html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
浏览器测试:
2.2.Backbone构造函数 initialize:function()
构造函数在每一次实例化对象的时候都会首先调用。 代码:
<html><head><scriptsrc="underscore.js">script><scriptsrc="jquery.js">script><scriptsrc="backbone.js">script>head><body><p>this is view event page p><scripttype="text/javascript">var BookModel = Backbone.Model.extend();
var book1 = new BookModel({
'title':'book1',
'description':'description1'
});
var BookView = Backbone.View.extend({
//Backbone类的构造函数
initialize:function(){this.listenTo(this.model,'change',this.render);
},
render:function(){
console.log('model is changed.');
}
});
var bookView1 = new BookView({
//传参
model:book1
});
script>body>html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
浏览器测试:
2.3.events 点击事件(单击【click】,双击【dblclick】)
代码:
<html><head><scriptsrc="underscore.js">script><scriptsrc="jquery.js">script><scriptsrc="backbone.js">script>head><body><p >this is view event page p><pid='p1'>p1p><pid='p2'>p2p><scripttype="text/javascript">var BookModel = Backbone.Model.extend();
var book1 = new BookModel({
'title':'book1',
'description':'description1'
});
var BookView = Backbone.View.extend({
//Backbone类的构造函数
initialize:function(){this.listenTo(this.model,'change',this.render);
},
render:function(){
console.log('model is changed.');
},
//使用events声明所有View的事件
events:{
'click':'handleClick',
'dblclick':'handleEldbClick'
},
//自定义回调,处理点击事件
handleClick:function(){
console.log('click event...');
},
handleEldbClick:function(){
console.log('double click event...');
}
});
var bookView1 = new BookView({
//传参
model:book1,
el:'#p1'
});
var bookView1 = new BookView({
//传参
model:book1,
el:'#p2'
});
script>body>html>
spring
【控制反转(IOC)/依赖注入(DI)】:
由容器控制程序之间的关系,而非传统实现中,由程序代码直接操控。这也就是所谓“控制反转”的概念所在:控制权由应用代码中转到了外部容器,控制权的转移,是所谓反转。
简单的说:对象的创建又容器(比如spring容器)来执行,程序里不直接new对象。
Web
【单点登录(SSO)】:SSO的定义是在多个应用系统中,用户
Bellman-Ford算法(根据发明者 Richard Bellman 和 Lester Ford 命名)是求解单源最短路径问题的一种算法。单源点的最短路径问题是指:给定一个加权有向图G和源点s,对于图G中的任意一点v,求从s到v的最短路径。有时候这种算法也被称为 Moore-Bellman-Ford 算法,因为 Edward F. Moore zu 也为这个算法的发展做出了贡献。
与迪科
Microsoft .NET Framework 3.5 Service Pack 1(完整软件包)
http://www.microsoft.com/zh-cn/download/details.aspx?id=25150
Microsoft .NET Framework 3.5 Service Pack 1 是一个累积更新,包含很多基于 .NET Framewo
public final class ViewStub extends View
java.lang.Object
android.view.View
android.view.ViewStub
类摘要: ViewStub 是一个隐藏的,不占用内存空间的视图对象,它可以在运行时延迟加载布局资源文件。当 ViewSt