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

Bootstrap JavaScript and Ajax (Pjax) don't work with 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 -> General
View previous topic :: View next topic  
Author Message
dkova
Smarty n00b


Joined: 03 Feb 2014
Posts: 2

PostPosted: Mon Feb 03, 2014 5:06 pm    Post subject: Bootstrap JavaScript and Ajax (Pjax) don't work with Smarty Reply with quote

Good day!

I write a PHP page with Smarty template engine and decided to use Bootstrap UI in my project (to be precise, Metro UI.
CSS works fine, but JavaScript doesn't work. I tried to use that without Smarty = all works excellent.

For example, hint:

index.tpl:

Code:
{config_load file="$tolangpath"}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>{#HomePageTitle#}</title>
{include file='libs.tpl'}
</head>
<body class="metro" style="background:url('./templates/images/bg-index.png') no-repeat;background-size:100%;">

<div style="text-align:right;padding-right:15px;">
<a href="#"
    data-hint="Title|This is a hint for Me"
    data-hint-position="top">
        Hover me...
</a>
                 
</div>
<div class="example" style="margin-left:35%;margin-top:10%;width:400px;">
                                <form action="./include/process/login.php">
                                    <fieldset>
                                        <img src="./templates/images/logo.png" align="center">
                                        <label>{#Login#}</label>
                                        <div class="input-control text" data-role="input-control">
                                            <input name="login" type="text" placeholder="{#LoginInput#}">
                                            <button tabindex="-1" class="btn-clear" type="button"></button>
                                        </div>
                                        <label>{#Password#}</label>
                                        <div class="input-control password" data-role="input-control">
                                            <input name="password" type="password" placeholder="{#PasswordInput#}">
                                            <button tabindex="-1" class="btn-reveal" type="button"></button>
                                        </div>
                                        <div class="input-control checkbox" data-role="input-control">
                                            <label>
                                                <input type="checkbox" checked="">
                                                <span class="check"></span>
                                                {#RememberMe#}
                                            </label>
                                        </div>
                              <br>
                                        <input type="submit" value="{#LoginButton#}">
                              <a class="button primary" href="./register" data-pjax="#main">{#RegisterButton#}</a>
                              <a class="button default" href="./recover">{#ForgotPassword#}</a>
                                    </fieldset>
                                </form>
                            </div>
</body>
</html>


libs.tpl:
Code:

              <link rel="stylesheet" href="./templates/css/metro-bootstrap.css">
            <link rel="stylesheet" href="./templates/css/passProtect.css">
              <script src="./templates/js/jquery-2.1.0.min.js"></script>
            <script src="./templates/js/passProtect.js"></script>
        <script src="./templates/js/jquery.widget.min.js"></script>
 <script type="text/javascript" src="./templates/js/metro.min.js"></script>
  <script type="text/javascript" src="./templates/js/jquery.pjax.js"></script>
 
                     <script type="text/javascript" src="./templates/js/metro-hint.js"></script>
   <script type="text/javascript">
    $(function(){
      // pjax
      $('ul a').pjax('#main')
    })
  </script>


Pjax (https://github.com/defunkt/jquery-pjax) doesn't work too. Please help to solve this problem.

P.S. Sorry for bad English Smile
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Feb 04, 2014 3:13 am    Post subject: Reply with quote

see here:

http://www.smarty.net/forums/viewtopic.php?t=4501
Back to top
View user's profile Send private message Visit poster's website
dkova
Smarty n00b


Joined: 03 Feb 2014
Posts: 2

PostPosted: Tue Feb 04, 2014 10:45 am    Post subject: Reply with quote

mohrt wrote:
see here:

http://www.smarty.net/forums/viewtopic.php?t=4501


But:
Quote:
Note: Smarty 3 no longer requires literal tags as long as the braces are surrounded by white space.
Back to top
View user's profile Send private message
Julian.Baker1
Smarty n00b


Joined: 15 Dec 2014
Posts: 4
Location: New York

PostPosted: Mon Dec 15, 2014 3:04 pm    Post subject: Can't work it out Reply with quote

I am new to this world and to Smarty and am trying to work around this problem myself. I went on the link shared, but I still can't figure it out. Could you please give a simpler explanation?
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Mon Dec 15, 2014 7:58 pm    Post subject: Reply with quote

Please explain the problem YOU are seeing.
Back to top
View user's profile Send private message
xhowiexo
Smarty n00b


Joined: 21 Jan 2015
Posts: 1

PostPosted: Wed Jan 21, 2015 4:32 pm    Post subject: Reply with quote

tried?

{literal}
javascript
{/literal}
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Sun Jan 25, 2015 4:13 am    Post subject: Reply with quote

dkova wrote:
mohrt wrote:
see here:

http://www.smarty.net/forums/viewtopic.php?t=4501


But:
Quote:
Note: Smarty 3 no longer requires literal tags as long as the braces are surrounded by white space.


Correct, so your braces must be surrounded by white space. from your example:

Code:
 $(function(){


Needs to be:

Code:
 $(function() {


To work with Smarty 3 without literal tags.
Back to top
View user's profile Send private message Visit poster's website
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sun Jan 25, 2015 9:01 am    Post subject: Reply with quote

mohrt wrote:
your braces must be surrounded by white space. from your example:

Code:
 $(function(){


Needs to be:

Code:
 $(function() {


To work with Smarty 3 without literal tags.


Shouldn't it only check the whitespace inside braces?
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Thu Jan 29, 2015 7:30 pm    Post subject: Reply with quote

For auto literal the opening brace must be followed by a whitespace.

Code:
{$foo}

is a Smarty tag


Code:
{ $foo}

is a literal
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Jan 30, 2015 1:05 am    Post subject: Reply with quote

AnrDaemon wrote:
mohrt wrote:
your braces must be surrounded by white space. from your example:

Code:
 $(function(){


Needs to be:

Code:
 $(function() {


To work with Smarty 3 without literal tags.


Shouldn't it only check the whitespace inside braces?


afaik it needs to be surrounded by whitespace (or BOF), maybe uwe changed it to work either way, I haven't tested recently.
Back to top
View user's profile Send private message Visit poster's website
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 -> General 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