[Solved] Taconite Example?

I tried to get a simple taconite example going and failed. Is there anyone more experience that can post a simple controller/view pair that shows how it works? A simple hello world call should suffice.

I am grappling with sending xhttprequest and getting it to the page in the right text/xml format and how it would get processed by the taconite js.

Here’s the jQuery Taconite JS library.

I gave it a show and ended up with all sorts of weird stuff :).

Thank you.

I finally found how to do it. For anyone who’s interested here’s a mini-tutorial on it.

Step 1: Download the taconite jquery plugin and place it in the js directory.

Step 2: For testing purposes, created a new controller.


<?php


class TacoController extends Controller

{

	public $defaultAction='index';

	public $layout='main_1col';

	


	/**

	 * This is the default 'index' action that is invoked

	 * when an action is not explicitly requested by users.

	 */

	public function actionIndex()

	{

		$this->render('index');

	}

	

	public function actionTaco()

	{

		if(Yii::app()->request->isAjaxRequest)

			$this->renderpartial('utaco');

	}


}

Step 3: Create a new view, in this case an index.php.


<div id="result3">

</div>


<br/><br/>


<div id="result1">

</div>


<br/>

<?php	echo CHtml::form();

		echo CHtml::ajaxLink('Do Taco',array('taco'),array('type'=>'POST'));

		echo '</form>';

	?>

<br/>


<div id="result2">

</div>




<?php	$baseUrl = Yii::app()->baseUrl;

		$clientScript = Yii::app()->getClientScript();

		$clientScript->registerScriptFile($baseUrl.'/js/jquery.taconite.js');

?>



This sets up an ajax link and 3 divs location for the updates.

Step 4: Create another view called utaco.php for the taconite instructions.


<?php header('Content-type: text/xml'); ?>

<taconite> 

    <append select="#result1"> 

        Thank you for your order!<br/>

    </append> 

    <append select="#result2"> 

        Your order has shipped! 

    </append> 

    <replace select="#result3"> 

        This is a replace taconite function!  Hence it won't append.

    </replace>

</taconite> 



That’s it.

I am a noobie at Yii so if anyone wants to rewrite parts of it or point out mistakes, I am happy to learn.

Looks great! Saved me some time as I was about to investigate taconite.

I’m sure you know, but the <form> is unnecessary.

If you like, you can do this:




Yii::app()->clientScript->registerScriptFile($baseUrl.'/js/jquery.taconite.js');



But if you want to use Yii’s assets, and keep the .js outside the base path; say, when you use the file in multiple apps. You can do, say:




$taconite = Yii::app()->basePath .'/../js/jquery.taconite.js';

$jsfile = Yii::app()->getAssetManager()->publish($taconite);

Yii::app()->clientScript->registerScriptFile($jsfile);



Ahhh… Thank you for the tips. I was just getting started with js too :).