0
我需要在javascript中獲得句柄模板。 所以我創建TPL文件夾模板文件和XML來自javascript的網絡資源
<resource type="download" name="tpl/" location="/tpl"/>
寫了這樣行,如果我把一些圖像到這個文件夾,我可以從CSS
.css
{
background: url(tpl/image.png);
}
得到它,如果我要得到這個圖片來自js AJS.$("css").css("background", "url(tpl/image.png)")
我有錯誤 - 文件未找到;
圖像文件是例如。在真正的我需要模板
AJS.$.ajax({
url: "tpl/backlog_coll.handlebars",
cache: true,
success: function(data) {
source = data;
template = Handlebars.compile(source);
$('#backlog_coll').html(template);
}
});
這種方法不發現模板了。它應該像'/jira/s/ru_RU-g6ghuq/773/3/1.0-SNAPSHOT/_/download/resources/com.swan.agile.swan-agile:swan-agile-scrumboard/tpl/「+ strName + 「.handlebars' – waldemar
實際上,在我的例子中,爲了便於解釋,我將路徑硬編碼爲」tpl「。實際上,您應該將其作爲變量值取出,以便您可以動態地填充該模板的路徑,如下所示: 函數fnGetTemplate(strPath,strName)if(Handlebars.templates === undefined || 模板:fnGetTemplate(strPath,strName);這個模板可以用來創建一個或多個模板。 – eshcol