|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
heohni Smarty Regular
Joined: 20 Sep 2006 Posts: 40
|
Posted: Wed Jun 30, 2010 1:47 pm Post subject: How to use JQuery/Ajax in my case? |
|
|
Hi,
I have this template:
Code: |
<select name="loc" size="1">
<option value="0">##NG_ALL_TOWNS##</option>
{foreach from=$cities key="key" item="value"}
...
...
|
On Change of another select box, I would like to update this select above.
In better words, I would like to call a jquery ajax function wich gives me the content for $cities back.
My question now, how can I load the new content of the variable $cities into my template on runtime?
I do not want to replace the html, I would like to keep the smarty foreach, as later in the select I have to do other smarty related things, so I dont want to disturb my oriinal way of doing.
Thanks folks in advance!! |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Jun 30, 2010 1:50 pm Post subject: |
|
|
You can't. Smarty variables are parsed on the server-side. You need to do your work client-side in javascript, no different than how you would handle it with just PHP. |
|
Back to top |
|
heohni Smarty Regular
Joined: 20 Sep 2006 Posts: 40
|
Posted: Wed Jun 30, 2010 3:12 pm Post subject: |
|
|
Pitty... but I understand what you are saying.
The only possible way would be to replace the html via jquery?
Because server-side means page refresh needed, right? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Jun 30, 2010 3:28 pm Post subject: |
|
|
Get it working with just PHP first, then use the same client-side code using Smarty. There are lots of scripts around the web that dynamically replace HTML elements with ajax/javascript. Any of them should work the same. |
|
Back to top |
|
|
|
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
|