2012-01-20 4 views
1

.cshtml 파일로 작성되었지만 js 파일로 이동하려는 일부 JQuery 템플릿 코드가 있습니다. 그러나 js 파일은 <script></script>을 인식하지 못합니다.js 파일에서 JQuery 템플릿을 작성하는 방법

다음은 tmpl의 예입니다.

<< 
<script type="text/x-jquery-tmpl" id="searchResult"> 
    <li><a href="#" data-name="${Name}">${Name}</a></li> 
</script> 
>> 

감사합니다.

답변

0

은이 선언 누락 :

<script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script> 
0

먼저 내가 템플릿 코드 및 스크립트 코드를 혼합에 대해 조언을하지만 디자인 결정 이잖아 것이다.

태그를 엔진이 케이크 케이크라고 생각할 수 있으므로 제거하십시오. 스크립트의 스크립트 태그.

0

lol, js 파일에 <script> 태그를 포함하지 않아도됩니다. Js fiels는 "가정"<script>입니다. 그러나 스크립트 태그 사이에있는 것들이 매우 기본적인 html로 보이고 html 파일로 이동해야하므로 여기에 설정에 익숙하지 않습니다. JS는 종종 일명, acctual 자바 스크립트를 사용 : 그것은 자바 스크립트 프로그램

일반 작동되지 않을 수도 있습니다

$(function() { 
    $(document).find("a").css("text-decoration", "none"); 
}); // this is an example of somthing typically found in a js file whereas 

// the following would generally be placed as in a .php VIEW file, thus MVC, Modal View Control 
<ul> 
    <li><a href="#" data-name="${Name}">${Name}</a></li> 
</ul> 

도 염두에 두어야 내 예를 JQuery와 마크 업을 사용

관련 문제