Javascript HTML()无法正常工作
显示事件的元素。事件来自JSON文件,由核心ajax加载 它有一个细节和一个非细节模板,可以进行切换。 首先加载非详细信息模板,然后可以切换其他信息,然后加载第二个模板Javascript HTML()无法正常工作,javascript,ajax,html,event-handling,polymer,Javascript,Ajax,Html,Event Handling,Polymer,显示事件的元素。事件来自JSON文件,由核心ajax加载 它有一个细节和一个非细节模板,可以进行切换。 首先加载非详细信息模板,然后可以切换其他信息,然后加载第二个模板 <template if="{{showDetail}}" > <core-ajax auto response="{{data}}" on-core-response="{{ajaxHandler}}" url ="http://loc
<template if="{{showDetail}}" >
<core-ajax auto
response="{{data}}"
on-core-response="{{ajaxHandler}}"
url ="http://localhost:8080/myevents/getDetailEvent={{nummer}}";
handleAs="json"></core-ajax>
<div class="showbox" >
<h2 id= "title"> </h2>
<p><b>Start:</b> {{data.startDate }}</p>
<p><b>Ende:</b> {{data.endDate }}</p>
<p id = "place"></p> </br>
<p id = "description"></p> </br>
<p id = "manager"></p> </br>
<button on-tap="{{toggleView}}">Less</button>
</div>
</template>
第一次加载组件时,injectBoundHTML工作并注入来自json的所有内容。当我按下切换按钮时,不会发生注射!如果我在dataChanged方法中添加JSON内容而不进行注入,它就可以工作了
我做错了什么
<template if="{{!showDetail}}" >
<core-ajax auto
response="{{data}}"
on-core-response="{{ajaxHandler}}"
url ="http://localhost:8080/myevents/getEvent={{number}}";
handleAs="json"></core-ajax>
<div class="showbox" >
<h2 id= "title"> </h2>
<p><b>Start:</b> {{data.startDate}}</p>
<p id = "description"></p> </br>
<button on-tap="{{toggleView}}">More</button>
</div>
</template>
dataChanged : function() {
if (this.data){
if(this.showDetail) {
this.injectBoundHTML(this.data.titleDe, this.$.titleDe);
this.injectBoundHTML(this.data.description, this.$.description);
this.injectBoundHTML(this.data.manager, this.$.manager);
} else {
this.injectBoundHTML(this.data.titleDe, this.$.titleDe);
this.injectBoundHTML(this.data.description, this.$.description);
}
}
}