Author Topic: Odd AJAX/PHP/Smarty/Javascript problem  (Read 5430 times)

0 Members and 1 Guest are viewing this topic.

Offline EvanAgeeTopic starter

  • Enthusiast
  • Posts: 62
  • Gender: Male
    • View Profile
    • EvanAgee.com
Odd AJAX/PHP/Smarty/Javascript problem
« on: October 01, 2008, 02:49:42 PM »
Okay, so this is a little difficult to explain....

I'm creating a PHP-powered AJAX interface that generates a list of items. What I'm wanting to do is make that list of items sortable so I'm using the scriptaculous Sortable.create method. Here's where it gets tricky.

So my php file displays my result set using a Smarty template. The problem is that the smarty template (which contains the javascript that triggers the Sortable.create method doesn't appear to be included in the template when it's displayed, there's a blank spot in the source where the JS should be.

Here's the JS that's at the bottom of my Smarty template:

Code: [Select]
<script type="text/javascript">
{literal}
<!--
Sortable.create("results_table", {
onUpdate:function(){
alert(Sortable.sequence('results_table').join(''));
}
});
-->
{/literal}
</script>

Any ideas?

Offline billshk13

  • Irregular
  • Posts: 1
    • View Profile
Re: Odd AJAX/PHP/Smarty/Javascript problem
« Reply #1 on: April 09, 2009, 03:18:09 PM »
I have the same exact problem, a simple javascript code enclosed by literal smarty tags and the script will not generate in the page. Has there been any luck or success on this issue?

Offline black.horizons

  • Enthusiast
  • Posts: 78
    • View Profile
Re: Odd AJAX/PHP/Smarty/Javascript problem
« Reply #2 on: May 19, 2009, 07:37:37 AM »
try putting the literal tag outside the <script type=""> and script e.g.

{literal}
<script type="text/javascript">
<!--
   Sortable.create("results_table", {
      onUpdate:function(){
         alert(Sortable.sequence('results_table').join(''));
      }
   });
-->
</script>
{/literal}

Offline AKA_ANTO

  • Irregular
  • Posts: 1
    • View Profile
Re: Odd AJAX/PHP/Smarty/Javascript problem
« Reply #3 on: April 01, 2010, 11:23:40 PM »
i know what the problem is... See,  probably u have ur js function in the template/html document where u want it to be executed, but turns out that u need it   where ur template/html document  is going to be located so it can be executed , is the same problem with images when we dont chance the url according to the document who gets the template....