ZajoPlugin - 0.3.0
You are currently browsing
the website for symfony 1
|Vojto Rinik||lead||ten.kinir <<ta>> otjov|
Copyright (c) 2008 Vojto Rinik <firstname.lastname@example.org>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Warning: This plugin is in Alpha state. Syntax is subject to change.
Please report all bugs to Vojto Rinik
This plugin is licensed under the MIT license. For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
This one also uses jQuery, but it uses also something new, called jQuery Enchant. That means you can create nice effects like with Script.aculo.us very easily.
As of now, there is not too much functionality. You can use basic helpers link_to_function, link_to_remote and form_remote_tag. These are static methods of ZajoHelper class, if you use helper ZajoHelper than you can use it as helper functions.
The another part is Enchant. There is ZajoEnchantHelper class, which provides methods for generating visual effects. In ZajoHelper there are helper functions for these methods too.
Enchant is created to work like Rails-RJS. If you write Enchant helpers into AJAX response, Zajo's filter will generate script with the code.
Let's install it!
Install the plugin
$ symfony plugin-install http://plugins.symfony-project.com/ZajoPlugin
Alternatively, if you don't have PEAR installed, you can download the latest package attached to this plugin's wiki page and extract it under your project's
If it is not installed yet, install the sfPJSPlugin, which is necessary to run this plugin
Copy all the files from /plugins/ZajoPlugin/web/js to your /web/js folder
Now it's time to do some configuration.
Enabled Zajo module in your settings.yml file.
all: .settings: enabled_modules: sfPJS, Zajo
ZajoFilter: class: ZajoFilter
$ symfony cc
In your template, use the ZajoHelper
Now the plugin should be ready to use. Let's try it in this mini-tutorial.
This is a small demonstration of principle of ZajoPlugin.
If you don't have one, create a new project, application and module.
$ mkdir zt $ cd zt $ symfony init-project zt $ symfony init-app a
Install the plugin according to instructions. When you're done, create a new module.
$ symfony init-module a test
Open generated actions.class.php, remove code inside executeIndex (leave it empty)
Open generated indexSuccess.php, add
Navigate your browser to /web/a_dev.php/test. You should see Hello World message.
Now add ZajoHelper, and create a new H1.
If you have everything done properly, there should be no errors now. Let's try an effect.
Reload your page, and the title should disappear! This was jQuery Enchant effect called Drop.
Now let's try something cooler. Let's create a simple form.
So this is very simple form. The url is test/send so we have to create send action. Open actions.class.php and add an empty executeSend method. Then add sendSuccess.php template, and write something like this:
"up")) ?> Comment posted.
This hide effect won't work as the drop effect couldn't be loaded. All effects are loaded automatically when you call them, but when you call an effect from Ajax response, it couldn't be added to the header of page. So you need to add it manually into indexSuccess.php:
Now if you try to post this form, it should display message 'Comment posted.', and the form should disappear.
You can discover all the functions of this plugin by checking source code.
ZajoPlugin is not finished yet. It has only those three basic Ajax functions, and visual effects functions (show, hide, toggle, effect).