I'm looking for a better way to do this:
var extended = $.extend(entity.data('namespace'), {
att1 : whatever,
att2 : whatever
});
entity.data('namespace', extended);
Any suggestions开发者_如何转开发?
.data()
doesn't know how to extend. If you want to extend, you have to do it yourself with jquery's .extend()
method. Recursive extension can be achieved by placing true
as the first parameter, so:
entity.data('namespace', $.extend(true, entity.data('namespace'), { ... }));
精彩评论