내 밑줄 템플릿에서 팀이라는 변수에 액세스하려고 시도하고 있으며 내가 지금까지해야했던 가장 어려운 작업 중 하나임이 입증되었습니다. 하지만 내 질문은 지금 - 왜 내 전화 자바 스크립트 코드 내에서 alert() 또는 window.alert() 호출 할 수 없습니다? 이 템플릿 스크립트 내부 가능한 어떤 이유로 경고()과는 Window.alert (대한Underscore 템플릿에서 창 및 경고 개체/기능을 사용할 수 없습니까?
<script id="user-home-main-table-template" type="text/template">
<table class="table">
<thead>
<tr>
<th>Club</th>
<th>Sport</th>
<th>Delete?</th>
</tr>
</thead>
<tbody>
<%
if(teams == null){
alert('teams is null'); //alert is not defined
window.alert('teams is null'); //window is not defined either
var teams = {};
}
for(var i=0; i
<teams.length; i++) { %>
<tr>
<td>
<a class="font-big" href='/users/<%=user._id%>/teams/<%=teams[i]._id%>/teamDashboard'>
<%=teams[i].club %>
</a>
</td>
<td>
<a class="font-big" href='/users/<%=user._id%>/teams/<%=teams[i]._id%>/teamDashboard'>
<%=teams[i].sport %>
</a>
</td>
<td>
<a class="btn btn-warning" onclick=window.userHomeMainTableView.deleteTeam('<%=teams[i]._id%>');>delete</a>
</td>
</tr>
<% } %>
</tbody>
</table>
</script>
)하지 : 여기
는 템플릿입니다. 이것에 대한 좋은 이유가 있습니까?
클라이언트 쪽 .... Handlebars로 전환합니다. –
템플릿을 채우는 백본보기가있는 경우 커피를 게시하십시오. – seebiscuit
템플릿이 생성되는 동안 코드를 중단시키기 위해'debugger' 행을 삽입 해보십시오. 이렇게하면 범위를 다시 시작할 수 있습니다. – seebiscuit