|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Shouko Smarty n00b
Joined: 30 Jul 2013 Posts: 1
|
Posted: Tue Jul 30, 2013 4:44 pm Post subject: Probleme mit Javascript in Verbindung mit Smarty |
|
|
Hi Leute,
ich arbeite mich zurzeit in Smarty ein und habe momentan ein Problem. Sobald ich den untenstehenden Code von Javascript in den Header meiner Seiten schreibe, spuckt mir Smarty folgende Fehlermeldung aus:
Fehlermeldung:
Code: |
Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "..\templates\backend_table_scripts.tpl" on line 99 ".tablesorterPager({container: $("#pager")});" - Unexpected ": ", expected one of: "}" , " " , ATTR' in C:\xampp\htdocs\test\lib\smarty\libs\sysplugins\smarty_internal_templatecompilerbase.php:667 Stack trace: #0 C:\xampp\htdocs\test\lib\smarty\libs\sysplugins\smarty_internal_templateparser.php(3144): Smarty_Internal_TemplateCompilerBase->trigger_template_error() #1 C:\xampp\htdocs\test\lib\smarty\libs\sysplugins\smarty_internal_templateparser.php(3209): Smarty_Internal_Templateparser->yy_syntax_error(2, ': ') #2 C:\xampp\htdocs\test\lib\smarty\libs\sysplugins\smarty_internal_smartytemplatecompiler.php(105): Smarty_Internal_Templateparser->doParse(2, ': ') #3 C:\xampp\htdocs\test\lib\smarty\libs\sysplugins\smarty_internal_templatecompilerbase.php(206): Smarty_Internal_SmartyTemplateCompiler->doCompile('<meta http-e in C:\xampp\htdocs\test\lib\smarty\libs\sysplugins\smarty_internal_templatecompilerbase.php on line 667
|
Javascript Code:
Code: |
<script type="text/javascript">
$(document).ready(function() {
$("#myTable")
.tablesorter({
// zebra coloring
widgets: ['zebra'],
// pass the headers argument and assing a object
headers: {
// assign the sixth column (we start counting zero)
6: {
// disable it by setting the property sorter to false
sorter: false
}
}
})
.tablesorterPager({container: $("#pager")});
});
</script>
|
Ohne Smarty funktioniert der Code einwandfrei.
Jemand eine Ahnung was ich falsch mache?
gruß
Shouko |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Jul 31, 2013 9:43 am Post subject: |
|
|
Siehe http://www.smarty.net/docs/en/language.escaping.tpl
{ und } wird in Javascript benutzt und ist auch Smarty delimiter.
Am einfachsten ist die Benutzung von Smarty's autoliteral Einstellung.
Dabei wird "{ " und " }" als Javascript interpretiert.
Deine Problemzeile sollte wie folgt aussehen:
Code: | .tablesorterPager({ container: $("#pager") }); |
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|