Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

smaty with xajax

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
shanto
Smarty n00b


Joined: 26 Aug 2006
Posts: 3

PostPosted: Wed Aug 30, 2006 5:23 pm    Post subject: smaty with xajax Reply with quote

is there any way to use smarty with xajax.if possible please mention the way with a simple example
Back to top
View user's profile Send private message Send e-mail
gnuffmaster
Smarty Elite


Joined: 13 Jul 2006
Posts: 440
Location: Düsseldorf, Germany

PostPosted: Thu Aug 31, 2006 12:52 pm    Post subject: Reply with quote

Sure this is possible and very simple. I use a lot xajax in smarty templates.

1st, define all the php functions you want to use and register them for xajax.

2nd put all the needed xajax stuff in your tpl:
[php:1:1c355f0295]$smarty->assign('xajax_javascript', $xajax->getJavascript());[/php:1:1c355f0295]

And in your template you can use all the js functions you defined for xajax automaticly.

Read also the examples on the xajax site.
Back to top
View user's profile Send private message Visit poster's website
mehmet soylu
Smarty n00b


Joined: 10 Jul 2007
Posts: 2

PostPosted: Tue Jul 10, 2007 11:47 pm    Post subject: Reply with quote

really thank you very much... Smile
Back to top
View user's profile Send private message
monotreme
Smarty Regular


Joined: 22 Feb 2004
Posts: 97
Location: USA

PostPosted: Wed Jul 11, 2007 6:16 am    Post subject: I too use xajax with smarty Reply with quote

all the time.
the only thing that might trip you up is the getting the generated javascript...

I do it like this:

all ajax setup stuff.....
$xajax->processRequests();

//now instead of printing it out right now, get it in a var
$inline .= "\n" . $xajax->getJavascript('classes/');

and $inline is a var where you accumulate all your inline javascript code and you pass it
to your master smarty template when u are ready to render.
_________________
Your online 24/7 box office
http://www.tixrus.us
Back to top
View user's profile Send private message Visit poster's website
Filip
Smarty n00b


Joined: 09 Dec 2007
Posts: 2

PostPosted: Sun Dec 09, 2007 1:24 pm    Post subject: Reply with quote

I use the exact same method and it works. But the generated HTML code is incorrect. The javascript is put at the beginning of the HTML page.

Code:

<script type="text/javascript">
var xajaxRequestUri="register.php";
var xajaxDebug=false;
var xajaxStatusMessages=false;
var xajaxWaitCursor=true;
var xajaxDefinedGet=0;
var xajaxDefinedPost=1;
var xajaxLoaded=false;
function xajax_ajax_checkUsername(){return xajax.call("ajax_checkUsername", arguments, 1);}
   </script>
   <script type="text/javascript" src="class_ext/xajax/xajax_js/xajax.js"></script>
   <script type="text/javascript">
window.setTimeout(function () { if (!xajaxLoaded) { alert('Error: the xajax Javascript file could not be included. Perhaps the URL is incorrect?\nURL: class_ext/xajax/xajax_js/xajax.js'); } }, 6000);
   </script>
<?xml version="1.0" encoding="iso-8859-1"?>
<DOCTYPE...>

<html xmlns="..." xml:lang="nl">

<head>
   <title>...</title>...


I'm trying to fix this issue, because I want to produce correct HTML Wink But so far I haven't found anything.

I managed to put the javascript at the correct place by putting the code between {php}{/php}. But then the function doesn't work anymore.

Any ideas?
Back to top
View user's profile Send private message
Filip
Smarty n00b


Joined: 09 Dec 2007
Posts: 2

PostPosted: Sun Dec 09, 2007 1:57 pm    Post subject: Reply with quote

Ok I found my mistake. Apparently I was using $xajax->printJavascript('') instead of $xajax->getJavascript('')...
Back to top
View user's profile Send private message
master_kaos
Smarty Regular


Joined: 02 Aug 2007
Posts: 54

PostPosted: Tue Dec 11, 2007 3:47 pm    Post subject: Reply with quote

Yes xajax and smarty are my 2 most used libraries for PHP Smile
I don't know what I would do without either.

ALso in the php ajax functions I use $smarty->fetch alot so I can output templates through ajax calls
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP