|
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 |
klintistwood Smarty n00b
Joined: 21 Jun 2014 Posts: 2
|
Posted: Tue Jul 29, 2014 6:50 pm Post subject: Javascript function availability |
|
|
Hello,
While playing with Smarty and JS, I bumped into a problem. A JS function declared in my main page is not available in my tpl files when I load them.
So more details...
Main file
<script>
$(document).ready(
function ButtonManager()
{
$( "button" ).click(function()
{ alert ('clicked'); }
});
</script>
<button>TEST</button>
in this case, when I click on the button, I get the alert as expected.
If I now add a div:
<div id="output"></div>
Then I use Ajax to get content from the server, I send back a tpl file with the same button in it. Everything is then stored in the previously created div. When I click on this button, nothing happens as if the function was not known by the tpl file. I can imagine that the tpl file alone doesn't know the function but how could I use a function declared in the main document ?
Thanks
Laurent |
|
Back to top |
|
epnb Smarty Rookie
Joined: 24 Sep 2014 Posts: 8
|
|
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
|