Categories > TinyButStrong general >

TBS and xajax

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: khanhvu
Date: 2006-12-08
Time: 06:12

TBS and xajax

Hi Skroll,

I have been googled for TBS and xajax (http://www.xajaxproject.org) so long but did'nt find any help.

People can make Smarty with xajax together but I love TBS and finding a way to make TBS and xajax working together.

I think this will be a perfect combination. Can you make it works ?

Thank you very much, Skroll.

By: ioguix
Date: 2006-12-08
Time: 10:37

Re: TBS and xajax

Hello,

What's your problem with xajax & TBS ?

I used already them together without any difficulties...

--
ioguix
By: khanhvu
Date: 2006-12-08
Time: 12:03

Re: TBS and xajax

Hi ioguix,

I'm newbie to xajax, actually I don't know how save xajax response object to TBS varialbe then out put to html

Here is the code:           

function refreshContent($formValues)
{
    $response = new xajaxResponse();   
    $newContent = 'aaa';   
    $response->addAssign('content', 'innerHTML', $newContent);   
    return $response;
}

// Generic xajax calls
$xajax->registerFunction('refreshContent');

$xajax->processRequests();

// Initial layout of the page
$TBS->LoadTemplate('main.html');
$TBS->MergeBlock('content', refreshContent);
$TBS->MergeField('xajaxJavascript', $xajax->getJavascript('./inc/xajax/'));
$TBS->Show(TBS_OUTPUT + TBS_NOTHING);

The output prints entire javascript code maded by xajax and ofcourse it didn't work.

Can you show me a working sample ?

Thank you very much.
By: ioguix
Date: 2006-12-08
Time: 12:47

Re: TBS and xajax

Hello,

Here a working sample :

XHTML :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <title>xajax example</title>
        <meta name="author" content="IoGuiX"/>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/>
        [xajax_js;htmlconv=no]
    </head>
    <body>
            <input type="button" id="ajax_btn" value="Click Me" />
            <select id="select_to_update">
                <option>--</option>
            </select>

        <script type="text/javascript">
        <!--
            document.getElementById('ajax_btn').onclick = function (e) {
                xajax_update_list('select_to_update');
            }
            //
        -->
        </script>
    </body>
</html>

php :
<?php
require_once ('xajax.inc.php');
require_once ('tbs_class.php');
/*
* Xajax stuff
*/
$xajax = new xajax();

$xajax->registerFunction('update_list');

function update_list($id) {

    $newContent = '<option>tralalala</option>';

    $objResponse = new xajaxResponse ();

    $objResponse->addAppend ( $id, 'innerHTML', $newContent );

    return $objResponse->getXML ();
}

$xajax->processRequests();

/* TBS stuffs */
$TBS = new clsTinyButStrong
    or die ('error on tbs\'s instance.');

/* Load the template */
$TBS->LoadTemplate( 'ex.xhtml' );

/* xajax js scripts header*/
$TBS->MergeField ( 'xajax_js', $xajax->getJavascript() );
   
$TBS->show ();
?>

It's a very simple sample. Each time you click the button, a 'tralalalala' option will be append to the select list.

Hope this will help you.

Cheers,
By: khanhvu
Date: 2006-12-08
Time: 15:19

Re: TBS and xajax

Thank you very much, ioguix

I will try your exampe and figure out.
By: khanhvu
Date: 2007-02-01
Time: 09:07

Re: TBS and xajax

Hi ioguix,

Thank you very much for your help on making TBS + xajax.

Now the problem is:

I'm using OOP in my CMS.

Can you make an instantiation like this:

$xajax = new xajax('index.php?action=login');

Notice: 'index.php?action=login'

I can not make this worked.

Waiting you ...
By: ioguix
Date: 2007-02-01
Time: 10:16

Re: TBS and xajax

Mh, sorry, I don't really anderstand what you are trying to do...

I don't anderstand what the link between OOP and GET parameters...

By the way, there is docs and a forum about xajax there : http://wiki.xajaxproject.org/Main_Page
By: sheepy
Date: 2007-02-05
Time: 09:10

Re: TBS and xajax

xajax and tbs are two different system, and so you cannot initiate both using their native constructor.

However you can always write a custom function or class that do it for you, allowing you to call both system's function from the same object.  Just don't expect you can save the trouble - you'll only get more.