[英]How to use smarty variable inside jquery?
Is it possible to use smarty variable inside jquery function ? 是否可以在jquery函数中使用smarty变量? For example: I have
/{$country}/{$lang}/8_about-ats.html
and I need to put this lane of code between data brackets in Jquery : location.href = $(this).data('smarty_code_here');
例如:我有
/{$country}/{$lang}/8_about-ats.html
,我需要将此代码行放在Jquery中数据括号之间: location.href = $(this).data('smarty_code_here');
. 。 Thank you very much.
非常感谢你。
Jquery: jQuery:
{literal}
<script type="text/javascript">
$(document).ready(function() {
$('#about_ats h3 a').click(function(e){
$(this).attr('href',"/{$country}/{$lang}/8_about-ats.html");
});
});
</script>
{/literal}
HTML: HTML:
<div id="about_ats" data-role="collapsible">
<h3><a href="#">About ATS</a></h3>
</div>
Jquery full code: jQuery完整代码:
<script type="text/javascript" src="/js/jquery-1.8.3.min.js"></script>
{literal}
<script type="text/javascript">
$(document).on("mobileinit", function () {
$.mobile.ajaxEnabled = false;
});
</script>
{/literal}
<script type="text/javascript" src="/js/jquery.mobile-1.2.1.min.js"></script>
{literal}
<script type="text/javascript">
$(document).ready(function() {
var arr = location.href.split("/")
var hostname = arr[2];
var countryCode = arr[3];
var languageCode = arr[4];
if(window.location.href == "http://"+hostname+"/"+countryCode+"/"+languageCode+"/" || window.location.href == "http://"+hostname+"/"+countryCode+"/"+languageCode+"/1_reseni-pro-prumyslovou-a-procesni-automatizaci-kvalitu-a-it.html"){
$('#nav').show();
$('#nav h4').hide();
$('#nav h4 a').trigger('click');
}else{
$('#nav').hide();
$('#nav h4').hide();
}
$('#languages').hide();
$('.search').hide();
$('.contacts').hide();
$('#menu').click(function(e){
e.preventDefault();
$('#nav').slideToggle('300');
if($("#nav").css('visibility') == 'hidden') {
}else{
$('#nav h4 a').trigger('click');
}
});
$('#search_menu').click(function(e){
e.preventDefault();
$('.search').slideToggle('300');
});
$('#globe_menu').click(function(e){
e.preventDefault();
$('.contacts').slideToggle('300');
if($(".contacts").css('visibility') == 'hidden') {
}else{
$('.contacts h2 a').trigger('click');
}
});
$('#lang_menu').click(function(e){
e.preventDefault();
$('#languages').slideToggle('300');
if($("#languages").css('visibility') == 'hidden') {
}else{
$('#languages h4 a').trigger('click');
}
});
$('#about_ats h3 a').click(function(){
{/literal}
alert("/{$country}/{$lang}/8_about-ats.html");
{literal}
});
});
</script>
{/literal}
Try this 尝试这个
{literal}
<script type="text/javascript">
$(document).ready(function() {
$('#about_us h3 a').click(function(e){
$(this).attr('href',"/{/literal}{$country}/{$lang}{literal}/8_about-ats.html");
});
});
</script>
{/literal}
Edit: Saw you solved the problem when I wrote my post :-) 编辑:看到我写我的帖子时,您解决了问题:-)
Try removing the {literal}
tags in your code. 尝试删除代码中的
{literal}
标签。
{literal}
{文字}
<script type="text/javascript">
$(document).ready(function() {
$('#about_us h3 a').click(function(e){
$(this).attr('href',"/{$country}/{$lang}/8_about-ats.html");
});
});
</script>
{/literal}
{/文字}
var data="<tr><td><input type='checkbox' class='case'/></td><td><label>{/literal}{$smarty.session.full_name|@ucfirst}{literal}</label></td>";
data +="<td><input type='text' id='i_tour_date"+i+"' class='se' name='tour_date[]'/></td></tr>";
$('#sds').append(data);
use literal open close tag... work well.............. 使用文字打开关闭标签...效果很好..............
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.