Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Probleme mit Javascript in Verbindung mit Smarty

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
Shouko
Smarty n00b


Joined: 30 Jul 2013
Posts: 1

PostPosted: Tue Jul 30, 2013 4:44 pm    Post subject: Probleme mit Javascript in Verbindung mit Smarty Reply with quote

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 &quot;..\templates\backend_table_scripts.tpl&quot; on line 99 &quot;.tablesorterPager({container: $(&quot;#pager&quot;)});&quot; - Unexpected &quot;: &quot;, expected one of: &quot;}&quot; , &quot; &quot; , 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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Jul 31, 2013 9:43 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP