Skip to content

Commit

Permalink
better docs
Browse files Browse the repository at this point in the history
  • Loading branch information
garak committed Jun 7, 2018
1 parent a65d909 commit 188eef2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/index.md
Expand Up @@ -36,7 +36,7 @@ If you prefer to see real code in action, you can find it in [this sandbox proje

In your template, include autocompleter.js file:

```jinja
``` twig
{% block javascripts %}
<script src="//code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
Expand All @@ -47,7 +47,7 @@ In your template, include autocompleter.js file:

Or, if you prefer Select2:

```jinja
``` twig
{% block javascripts %}
<script src="//code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/select2/3.5.4/select2.min.js"></script>
Expand All @@ -65,7 +65,7 @@ In your FormType, change field type from `entity` to `autocomplete`:

``` php
<?php
// App/Form/BookType.php

// ...
use App\Entity\Author;
use PUGX\AutocompleterBundle\Form\Type\AutocompleteType;
Expand Down Expand Up @@ -115,7 +115,7 @@ inside your field. Here, a possible `findLikeName` repository method is used, to
search with `LIKE` statement (e.g. "da" will find "Dante Alighieri").
A possible twig template for first action:

```jinja
``` twig
[{% for author in results -%}
{{ {id: author.id, label: author.name, value: author.name}|json_encode|raw }}
{# use "value" instead of "id" key, if you use jquery-ui #}
Expand All @@ -130,7 +130,7 @@ Note that this action should work with or without `$id` parameter, since such pa

Last, in your JavaScript file, you should enable the autcompleter with following code:

```
``` javascript
$('#book_author').autocompleter({
url_list: '/author_search',
url_get: '/author_get/'
Expand All @@ -147,7 +147,7 @@ such values from JavaScript using DOM (e.g. using some identifiers).
If you want to pass additional configuration options to Select2, you can use the `otherOptions` parameter.
Example:

```
``` javascript
var options = {
url_list: $('#url-list').attr('href'),
url_get: $('#url-get').attr('href'),
Expand All @@ -169,7 +169,7 @@ Example:

``` php
<?php
// App/Form/Type/AuthorFormFilterType.php

// ...
use App\Entity\Book;
use PUGX\AutocompleterBundle\Form\Type\AutocompleteFilterType;
Expand Down

0 comments on commit 188eef2

Please sign in to comment.