Jump to content

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?

Link to comment
https://forums.phpfreaks.com/topic/126648-odd-ajaxphpsmartyjavascript-problem/
Share on other sites

  • 6 months later...
  • 1 month later...

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}

  • 10 months later...

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.