0

When I put SMARTY variable between {literal}{$txt_more}{/literal} in Jquery then in source code it display right text (více without quotes) but in console it show this error: ReferenceError: v\u00EDce is not defined - this error I thought is because it is not in quotes but when I put it into quotes {literal}'{$txt_more}'{/literal} it show in source code as 'více' but not display as text between tags strong with class show_text (tags are empty inside). Can you help me ? Thank you very much.

Jquery with SMARTY:

$('.show_text').text({/literal}'{$txt_more}'{literal}); // verison with quotes is without error but still not display text between tags with class show_text

$('.show_text').text('show more'); // with show more typed it displays as it should on website

HTML:

<a href="#">
  <strong class="show_text" style=" margin-top: 5px; text-align:center; overflow:hidden;white-space:nowrap;position:absolute; z-index:2"></strong>
  <img style="position:relative;" class="cond-arr" src="/css/showmore.png" alt="show_more" />
</a>
1
  • 1
    What about: $('.show_text').text("{literal}{$txt_more}{/literal}"); ??? Commented Mar 27, 2014 at 16:09

2 Answers 2

1

Wrong quoting, should be:

$('.show_text').text("{/literal}{$txt_more}{literal}");
Sign up to request clarification or add additional context in comments.

3 Comments

That would produce the opposite of the intended result
@Borgtex i don't know at all smarty, could you elaborate about 'opposite' result? EDIT: ok, was thinking it was a typo in OP's code, my bad
@Alex Thank you! And indeed, was my first answer before switching it. PS: that's really strange notation imho
0

If you're using Smarty 3, you don't need {literal} anymore, just make sure that there is always a space after any { in your code

If using smarty 2, you don't need to be so specific with literal, remember that the problem is only when there is a "{". Your code will look much cleaner with one of this solutions:

{/literal}
$('.show_text').text('{$txt_more}');
{literal}

or using a javascript variable at the start of your code and surrounding everything else with literal just to be safe

txt_more='{$txt_more}';

{literal}
...
$('.show_text').text(txt_more);
...
{/literal}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.