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

Can't Get javascript to work in 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
varcorb
Smarty n00b


Joined: 08 Oct 2014
Posts: 1

PostPosted: Wed Oct 08, 2014 9:22 pm    Post subject: Can't Get javascript to work in smarty Reply with quote

Hello,

I have a javascript function that works fine in an html file that has a up and down arrow move the curser on a table that is editable.

But when i place it in smarty it doesn't load it. Any Suggestions?

Code:
<script type="text/javascript">
jQuery(document).ready(function(){
$('td').keydown(function(evt){
    if(evt.keyCode == 40){
        event.preventDefault();
        var cellindex = $(this).index()
        var rowindex = $(this).parents('tr').index() + 1
        $(this).parents('table').find('tr:eq('+rowindex+') td:eq('+cellindex+')').focus()
    }else if (evt.keyCode == 38){
            event.preventDefault();
        var cellindex = $(this).index()
        var rowindex = $(this).parents('tr').index() - 1
        $(this).parents('table').find('tr:eq('+rowindex+') td:eq('+cellindex+')').focus()
    }
})
});
</script>

Code:

<table class="table zebra-style">
    <thead>
         <td colspan = "9">
            Material Takeoff
        </td>
        <td colspan = "9">
            Material to Buy
        </td>
      <tr>
        <th>Note</th>
        <th>Part #</th>
      </tr>
    </thead>
    <tbody>
    {foreach from=$results item=row}
      <tr>
        <td id="Part_Note:{$row.Part_Id}" contenteditable="true">{$row.Part_Note}</td>
        <td id="Part_Number:{$row.Part_Id}" contenteditable="true">{$row.Part_Number}</td>
      </tr>
{/foreach}
    </tbody>
 </table>
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Wed Oct 08, 2014 10:51 pm    Post subject: Reply with quote

Did you escape the Smarty default delimiter { and } for the javascript sections?

See http://www.smarty.net/docs/en/language.escaping.tpl
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 -> 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