Reputation: 241
Is it possible to use smarty variable inside jquery function ? 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');
. Thank you very much.
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:
<div id="about_ats" data-role="collapsible">
<h3><a href="#">About ATS</a></h3>
</div>
Jquery full code:
<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}
Upvotes: 0
Views: 3836
Reputation: 29
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..............
Upvotes: 0
Reputation: 1373
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 :-)
Upvotes: 3
Reputation: 2169
Try removing the {literal}
tags in your code.
{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}
Upvotes: 0