Download the PHP package troopers/ajax-bundle without Composer

On this page you can find all versions of the php package troopers/ajax-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ajax-bundle

Troopers

License Version Packagist DL SensioLabsInsight Twitter Follow

TroopersAjaxBundle

Description

This bundle offers a simple structure to run ajax actions. For each kind of action (link or form), you have to add a data-toggle="ajax" to the tag ( a, form ) and to specify the id of the container to update in the update attribute.

Installation

With Composer :

Add this line in your composer.json file :

"troopers/ajax-bundle": "dev-master"

Declare the bundle in your AppKernel.php:

public function registerBundles() {
    $bundles = array(
        [...]
        new Troopers\AjaxBundle\TroopersAjaxBundle(),
        [...]

Configuration

AsseticInjectorBundle way

If You have installed our AsseticInjectorBundle bundle:

  1. Thank you, you are awesome for us ;)
  2. It may "just work" but if not, you'll have to check the injector tags in your javascript (injector="foot") and stylesheet (injector="head") blocks.

The normal way

Just load ajax.jsand ajax.css in your template:

Examples

Links

<a href="ajaxCall" data-toggle="ajax" data-update="updater-container">Click me</a>
<div id="updater-container">Here will stand the ajaxCall response</div>

Forms

<form action="ajaxAction" method="POST" data-toggle="ajax" data-update="updater-ajaxAction-container">
  <input type="submit" value="Ok save me" />
</form>

<div id="updater-ajaxAction-container">Here will stand the ajaxAction response</div>

Link that updates a form (using the data-form jquery selector)

<a
    data-toggle="ajax"
    data-form="#search"
    data-update="result-panel"
    data-update-strategy="append"
    href='your_url'>
    Show more
</a>

If the link contains the data-form property, it will submit the form using the properties of the link.

Auto-refresh a form

You can automatically send an ajax request to update your form when an input/select change, just add the data attribute "data-refreshonchange":

Then in your controller's action:

For some reason, you would not refresh some parts of your form (for example an input type="file"). Then, add the data attribute 'data-ignoreonchange="$some_unique_id"'.

Extra features

As you probably noticed, you can automatically set a container for your ajax response. Actually, you can do some others features :

Update strategy

The data-update-strategy attribute is used to define the function to use to integrate your ajax content with the container your already set by using the data-update attribute. So if you want to, you can tell the library to put after, before, append, prepend or a custom function. Note that, the default behavior is to simply replace the content of the container by the html function.

Let's take an example. If you want your ajax content to be simply added in the end of your container, here is your code :

<a href="ajaxCall" data-toggle="ajax" data-update="updater-container" data-update-strategy="append">Click me</a>
<div id="updater-container">This sentence will stay here and the ajax content will be displayed just after</div>

Effect

By default, when we load ajax content, a small effect is run : hide + fadeIn (if container not empty) hide + slideDown (if container is empty). If this effect does not feed your needs, you can set your own by filling the data-effect attribute. For example :

<a href="ajaxCall" data-toggle="ajax" data-update="updater-container" data-effect="slideDown">Click me</a>
<div id="updater-container">This container will be hidden, the ajax content will be placed here and then the slideDown function will be used to display this</div>

If you do not want any effect, you can just add the data attribute noEffect on the link (or the target) tag. For example, on the link :

<a href="ajaxCall" data-toggle="ajax" data-update="updater-container" data-noEffect=true>Click me, no effect</a>
<div id="updater-container">This container will be hidden without any effect if you click</div>

or directly on the target :

<a href="ajaxCall" data-toggle="ajax" data-update="updater-container">Click me, no effect</a>
<a href="ajaxCall" data-toggle="ajax" data-update="updater-container" data-effect="fadeIn">Click me (fadeIn)</a>
<div id="updater-container" data-noEffect=true>This container will be hidden with or without an effect, according by the link you choose</div>

In this last example, the first link'll do the ajax call without any effect because of the data-noEffect on the target container and the second, because of its override will trigger a fadeIn effect.

Bootstrap Modal use

This is the is the youngest of the ajax feature's family, now you can simply trigger bootstrap modal by simply adding data-toogle="modal" on the link you decides to :

<a href="ajaxCall" data-toogle="ajax-modal">Click me and the ajax result will pop in a beautiful popup</a>

This will work "as is" but to have a cool appearence, you will have to add the correct markup inside the modal. More info in the Twitter Bootstrap modal doc

Overwrite the loader

AjaxBundle comes with a default loader and an overlay. If you want, you can change it by defining the loader's markup you want to use in window.loader

This example will tell ajax.js to use the /img/loading.gif and will disable the overlay.


All versions of ajax-bundle with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package troopers/ajax-bundle contains the following files

Loading the files please wait ....