License

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 conditions:

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.

Release 1.1.4 - 22/10/2008

Release 1.0.6 - 23/10/2008

Release 1.0.5 - 22/10/2008

Release 1.0.4 - 22/10/2008

Jquery Plug-In

The sfJqueryReloadedPlugin offers helpers that integrate the Jquery Javascript framework.

Support

Please contact the sfJqueryReloadedPlugin Google group. That is the best place to report bugs. Some of the maintainers may also be found in the
#symfony channel @ Freenode IRC.

Licence

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.

Introduction

Symfony 1.0 offered a set of PHP helper functions which invoked popular AJAX functionality, such as forms that update particular page elements rather than the entire page, autocomplete/typeahead, and the like. However, these helpers were built on Prototype, while jQuery has since become a clearly superior JavaScript library. Also, in Symfony 1.2 these helpers were deprecated and in Symfony 1.4 they are gone. sfJqueryReloadedPlugin is a reimplementation of these helper functions that uses the jQuery library instead of Prototype.

Just make sure you import the helper group jQuery with a use_helper call:

Optional: change jquery_web_dir in setting.yml if you are
not using the traditional symbolic link to the webdir of the plugin
(or copying the plugin's /web folder to a folder called sfJqueryPlugin
in your web dir, which will also work automatically with our defaults).

all:
.settings:
jquery_web_dir: /sfJqueryPlugin

Optional: within that folder's /js/ subfolder you might have a different
version of jquery other than a minimized 1.3.1 which is what
you currently get if you allow the plugin to supply it. This can be a relative path
if the file is located in a different folder.

all:
.settings:
jquery_core: jquery-1.3.1.min.js

Optional: specify different versions of the ui and autocomplete plugins, which would be looked for in the /js/plugins/ subfolder of your jquery_web_dir. Again, you can use relative paths relative to that location in web space if they are in a different place.

If you are running your websites under Microsoft Windows, you also have to manually copy the ./web
directory of the plugin in the %SF_ROOT_DIR%/web directory of your project
and rename it to sfJqueryReloadedPlugin. (The ./symfony plugin:publish-assets task should be able to do this for you.)

Basic syntax

Declaring the helper in templates

When you use functions that require jQuery plugins, specifically
jq_sortable_element and jq_input_auto_complete_tag, the appropriate
JavaScript files are automatically added. However, if you are attempting
to do this from your layout.php (including via a component or
partial referenced by layout.php rather than an action template),
it will not work because get_javascripts() has already been invoked.
To resolve this issue, call:

<?php jq_add_plugins_by_name(array('sortable', 'autocomplete')) ?>

At the top of your layout.php file, or just add the js files for the
plugins you need directly to your project's view.yml file. The first
solution is more maintainable because it means you don't have to pay
close attention when we update to a newer release of a plugin.

Using Jquery methods

To use Jquery methods, refer to Chapter 11 of the classic Symfony 1.0 documentation Ajax Integration. All helper functions described in that chapter can be used with the jq_ prefix.

Note that jQuery and Prototype select elements differently. In cases where selecting just one element is the only thing that makes sense, the helper functions automatically prepend a # so that the selector behaves as it would in Prototype.