javascript oop 和这个
给出以下代码:
JE.events = {
self: this,
controller: {
init: function(){
$(".monthheader").click(function () {
JE.events.model.get($(this).attr('title'));
return false;
});
return this;
}
},
model: {
get: function(monthnum){
...
}
}
}
我如何将调用替换
JE.events.model.get(..);
为类似的内容
self.model.get(..);
整个代码或多或少都在这个要点 https ://gist.github.com/966270。这个想法是在 js 中创建一个非常简单的 MVC(我的第一次尝试),我可以轻松地重用它。欢迎改进!
Given the following code:
JE.events = {
self: this,
controller: {
init: function(){
$(".monthheader").click(function () {
JE.events.model.get($(this).attr('title'));
return false;
});
return this;
}
},
model: {
get: function(monthnum){
...
}
}
}
How would i replace the call to
JE.events.model.get(..);
by something like
self.model.get(..);
The whole code is more or less in this gist https://gist.github.com/966270 . The idea is to create a really simple MVC in js (my first attempt) that i can reuse easily. Improvements are welcome!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能还想查看 backbone 或 spine 是轻量级的 MVC 框架。
它们为您提供一些简单的抽象和大量的控制。还有小而简单的。
如果我从头开始编写一个微型 MVC 框架,它将收敛到主干或骨干,因此最好使用这两者之一。
You may also want to look at backbone or spine which are lightweight MVC frameworks.
They give you some simple abstractions and a lot of control. There also small and simple.
If I were to write a micro MVC framework from scratch it would converge to either backbone or spine so it might be better to use one of those two.