我正在尝试找到渲染li元素的最佳方法:
我读过我永远不应该替换this.el
所以我似乎必须在我的LiView render()函数中解开我的模板:
// replace element content with html generated from template
var $rendered = $.tmpl(this.template, this.model.toJSON());
this.el.html($rendered.unwrap().html());
Run Code Online (Sandbox Code Playgroud)
我只是得到里面的内容$rendered,因为我不应该替换它.
但我应该如何转移属性?
我试过了 :
this.el.attr('class', $rendered.attr('class'));
this.el.attr('title', $rendered.attr('title'));
Run Code Online (Sandbox Code Playgroud)
但它取代了属性......而有些(如jQuery ui ui-draggable)可能会丢失.
这一切看起来有点笨拙......
谢谢 !
是否有一种干净的方式以某种方式使用underscore.js _.extend函数(或任何其他)来创建从基类Error类继承的自定义错误类?我正在寻找一种类似骨干的方式来做到这一点.
试过这个:
InternalError = function(message, args) {
message || (message = {});
this.initialize(message, args);
};
_.extend(InternalError.prototype, Error.prototype, {
initialize: function(message, args) {
this.message = message;
this.name = 'InternalError';
}
});
var error1 = new Error('foo');
var error2 = new InternalError('bar');
console.warn(error1, error2);
throw error2;
Run Code Online (Sandbox Code Playgroud)
但它不起作用:(.
我在Backbone遇到了一些奇怪的事情:
普通父类的所有子类似乎都与其兄弟姐妹一起获得"引用"属性...... !!
检查这个简单的测试用例:
var MyParentClass = Backbone.View.extend({
items:['foo'],
initialize: function() {
}
});
var MyFirstChildrenClass = MyParentClass.extend({
initialize: function() {
MyFirstChildrenClass.__super__.initialize.apply(this, arguments);
console.warn('MyFirstChildrenClass::initalize()');
this.items.push('bar');
}
});
var MySecondChildrenClass = MyParentClass.extend({
initialize: function() {
MySecondChildrenClass.__super__.initialize.apply(this, arguments);
console.warn('MySecondChildrenClass::initalize()');
console.warn(this.items); // expecting [foo] & getting [foo,bar] !
}
});
var firstInstance = new MyFirstChildrenClass();
var secondInstance = new MySecondChildrenClass();
Run Code Online (Sandbox Code Playgroud) 有没有办法使用openssl为PKCS#7签名消息传递额外的经过身份验证的属性?我坚持使用命令行.
我目前正在使用:
openssl smime -sign -outform DER -md sha1 -binary -signer my.crt -inkey my.key
Run Code Online (Sandbox Code Playgroud)
我没有在openssl cli帮助中找到任何相关的选项.
更多信息 :
我目前正在尝试在NodeJS中构建一个SCEP(http://tools.ietf.org/pdf/draft-nourse-scep-23.pdf)服务器.
SCEP规范要求建立PKCS#7签名pkiMessages,
The SignerInfo MUST contain a set of authenticatedAttributes (see PKCS#7 [RFC2315] Section 9.2 as well as Section 3.1.1 in this document). All messages MUST contain
* an SCEP transactionID attribute
* an SCEP messageType attribute
* an SCEP senderNonce attribute
* any attributes required by PKCS#7 [RFC2315] Section 9.2 If the message is a response, it MUST also …Run Code Online (Sandbox Code Playgroud) 我最近开始在我的NodeJS express模块中使用包装匿名函数,因为它以某种方式帮助我编写更清晰的代码.
但是我不确定这在Node环境中是否被认为是错误/良好的做法(可能是一些调试/优化问题?),它被Coffeescript广泛使用,所以我想它一定没问题,是吗?
Express Controller示例:
module.exports = (function() {
function LinksController() {}
var moment = require('moment'),
_ = require('underscore'),
Q = require('q');
LinksController.edit = function edit(req, res, next) {
...
}
return LinksController;
})();
Run Code Online (Sandbox Code Playgroud) javascript ×3
backbone.js ×2
inheritance ×2
class ×1
cryptography ×1
express ×1
node.js ×1
openssl ×1
pkcs#7 ×1
rendering ×1
view ×1