Add support for 'content' attribute, to create namespace for template using something other than its ID

This commit is contained in:
Nathan Gray 2012-05-24 21:36:03 +00:00
parent 775d08a89b
commit 7e92918f9e

View File

@ -48,7 +48,11 @@ var et2_template = et2_DOMWidget.extend({
"name": "Language",
"type": "string",
"description": "Language the template is written in"
}
},
"content": {
"name": "Content index",
"default": et2_no_init
},
},
createNamespace: true,
@ -56,7 +60,12 @@ var et2_template = et2_DOMWidget.extend({
/**
* Initializes this template widget as a simple container.
*/
init: function() {
init: function(_parent, _attrs) {
// Set this early, so it's available for creating namespace
if(_attrs.content)
{
this.content = _attrs.content;
}
this._super.apply(this, arguments);
this.div = document.createElement("div");
@ -102,6 +111,22 @@ var et2_template = et2_DOMWidget.extend({
}
},
/**
* Override parent to support content attribute
*/
checkCreateNamespace: function() {
if(this.content)
{
var old_id = this.id;
this.id = this.content;
this._super.apply(this, arguments);
}
else
{
this._super.apply(this, arguments);
}
},
getDOMNode: function() {
return this.div;
}