Jump to content

Archived

This topic is now archived and is closed to further replies.

EvanAgee

Odd AJAX/PHP/Smarty/Javascript problem

Recommended Posts

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:

 

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

 

Any ideas?

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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}

Share this post


Link to post
Share on other sites

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....

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.