2011-02-08 2 views
2

...jquery 스크립트를 smarty tpl 파일에 추가하려고하면 어떤 문제가 있습니까? 그것은 나에게 빈 페이지를 제공

당신은 그렇지 않으면 유식 잠재적으로 치명적인 오류와의 흰색 페이지에 이르는, 자바 스크립트 코드에서 중괄호 내에서 물건을 해석하려고합니다 {literal} 태그로 묶어야 할 필요가
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
{if $tplSeoFile}{include file="$modulePath/$tplSeoFile"}{/if} 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<meta name="Author" content="" /> 
<meta name="Robots" content="index, follow" /> 
<meta name="Revisit-after" content="10 days" /> 
<link rel="stylesheet" href="img/cms/css/reset.css" type="text/css" media="all" /> 
<link rel="stylesheet" href="img/cms/css/960.css" type="text/css" media="all" /> 
<link rel="stylesheet" href="img/cms/css/master.css" type="text/css" media="all" /> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> 
<script type="text/javascript"> 
$(document).ready(function() { 

    //Default Action 
    $(".tab_content").hide(); //Hide all content 
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab 
    $(".tab_content:first").show(); //Show first tab content 

    //On Click Event 
    $("ul.tabs li").click(function() { 
     $("ul.tabs li").removeClass("active"); //Remove any "active" class 
     $(this).addClass("active"); //Add "active" class to selected tab 
     $(".tab_content").hide(); //Hide all tab content 
     var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content 
     $(activeTab).fadeIn(); //Fade in the active content 
     return false; 
    }); 

}); 
</script> 


</head> 
+0

스크립트를 제거해 보셨습니까? 그때 그것을로드합니까? – cromestant

답변

2

죽음 :

{literal} 
<script> 
$(document).ready(function() { 

    //Default Action 
    $(".tab_content").hide(); //Hide all content 
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab 
    $(".tab_content:first").show(); //Show first tab content 

    //On Click Event 
    $("ul.tabs li").click(function() { 
     $("ul.tabs li").removeClass("active"); //Remove any "active" class 
     $(this).addClass("active"); //Add "active" class to selected tab 
     $(".tab_content").hide(); //Hide all tab content 
     var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content 
     $(activeTab).fadeIn(); //Fade in the active content 
     return false; 
    }); 

}); 
</script> 
{/literal} 

참조는 http://www.smarty.net/docsv2/en/language.function.literal.tpl

+0

고마워요 - 작동합니다 – easyrider

+0

@easyride - 오신 것을 환영합니다 – karim79

+0

해결 된 마크가 좋을 것입니다! 커뮤니티의 경우 – cromestant

0

A는 here는 외부 JS 스크립트 또는 m에 코드를 취할 중 하나가 필요 진술 noconflict 모드에서 Jake! jQuery ('')로 $ ('')를 매우 간단하게 변경하십시오.

+0

내가 선택한 페이지의 두 번째 팁 (사용자가 고른 팁)이 어떻게 도움이되는지는 알 수 없습니다. –

+0

이 '$() 대신 jQuery() 사용.' 이것은 jQuery (및 다른 많은 js 프레임 워크)가 객체를 $ 기호에 매핑하기 때문입니다. 객체를 직접 사용할 수도 있습니다. 대부분의 프레임 워크는 충돌 없음 모드를 제공하므로 다른 프레임 워크를 동시에 사용할 수 있습니다 (대개 같은 심볼을 매핑합니다). 심볼을 사용하지 않을 이유가 없으므로 해제하지 않기 때문에 충돌이 없다고 덧붙였다. pro-tip : 객체를 다른 심볼에 매핑하고이를 사용할 수도 있습니다 (var j = jQuery.noConflict(); j ('# div') ......) – cromestant

2

차라리 더 쉽게 {literal} {/ literal}을 사용하고 싶습니다.

관련 문제