我正在测试驱动语义用户界面,我很好奇是否可以在动态添加的HTML模板上自动应用UI组件行为?
示例:
getTemplateHTML(url).then(function (html) {
$(someElement).html(html);
// apply behaviours to $(someElement)'s content
});
答案 0 :(得分:0)
You should add SUI component's initialization code to any callback that you receive after rendering your dynamic template.
If you are talking about Meteor, than you should use template data<-read.table(text=
"e0AL fxAL e0CO fxCO e0BR fxBR anos
51.8 5.9 50.6 6.8 51.0 6.2 1955
54.7 5.9 55.2 6.8 53.5 6.2 1960
57.1 6.0 57.9 6.8 55.9 6.2 1965
59.1 5.6 60.1 6.2 57.9 5.4 1970
61.2 5.1 61.8 5.0 59.8 4.7 1975
63.4 4.5 64.0 4.3 61.8 4.3 1980
65.4 3.9 66.9 3.7 63.5 3.8 1985
67.3 3.4 68.0 3.2 65.5 3.1 1990
69.1 3.0 68.7 3.0 67.5 2.6 1995
70.9 2.8 70.3 2.8 69.5 2.5 2000
72.4 2.5 71.7 2.6 71.1 2.3 2005
73.3 2.3 72.9 2.5 72.1 1.9 2010
74.3 2.2 73.8 2.4 73.2 1.8 2015
75.2 2.0 74.6 2.3 74.2 1.7 2020
76.0 2.0 75.4 2.2 75.2 1.6 2025
76.8 1.9 76.2 2.1 76.1 1.6 2030
77.6 1.9 76.9 2.1 77.1 1.6 2035
78.4 1.9 77.6 2.0 77.9 1.7 2040
79.1 1.8 78.3 1.9 78.7 1.7 2045
79.8 1.8 79.0 1.9 79.5 1.7 2050
80.5 1.8 79.7 1.9 80.3 1.7 2055
81.1 1.8 80.3 1.8 80.9 1.8 2060
81.7 1.8 80.9 1.8 81.6 1.8 2065
82.3 1.8 81.4 1.8 82.2 1.8 2070
82.8 1.8 82.0 1.7 82.8 1.8 2075
83.3 1.8 82.5 1.7 83.4 1.9 2080
83.8 1.8 83.0 1.7 83.9 1.9 2085
84.3 1.9 83.5 1.8 84.4 1.9 2090
84.7 1.9 83.9 1.8 84.9 1.9 2095
85.1 1.9 84.3 1.8 85.4 1.9 2100", header=T)
require(plotrix)
twoord.stackplot(lx=data$anos, rx=data$anos,
ldata=cbind(data$e0AL, data$e0BR, data$e0CO),
rdata=cbind(data$fxAL, data$fxBR, data$fxCO),
lcol=c("black","red", "blue"),
rcol=c("black","red", "blue"),
ltype=c("l","o","b"),
rtype=c("l","o","b"),
lylab="Años de Vida", rylab="Hijos x Mujer",
xlab="Tiempo",
main="Mortalidad/Fecundidad:1950–2100",
border="grey80")
legend("bottomright", c(paste("Proy:",
c("A. Latina", "Brasil", "Colombia"))), cex=1,
col=c("black","red", "blue"), lwd=2, bty="n",
lty=c(1,1,2), pch=c(NA,1,1) )
callback, as I've answered in Access HTML after this.render() in Iron Router