Explorar o código

Agregado del llamado de una funcion que se ejecuta la seleccionar el cliente

gabriel %!s(int64=7) %!d(string=hai) anos
pai
achega
09c8846735
Modificáronse 1 ficheiros con 11 adicións e 2 borrados
  1. 11 2
      Resources/views/Type/remote_client_widget.html.twig

+ 11 - 2
Resources/views/Type/remote_client_widget.html.twig

@@ -39,8 +39,11 @@
                         minLength: 3,
                         source: function (request, response) {
                             $.ajax({
-                                url: '{{ path(ajax_url) }}?q=' + request.term,
+                                url: '{{ path(ajax_url) }}',
                                 type: "GET",
+                                data: {
+                                    q: request.term
+                                },
                                 success: function (data) {
                                     response($.map(data.results, function (el) {
                                         return {
@@ -54,13 +57,19 @@
                         select: function (event, ui) {
                             this.value = ui.item.label;
                             $('input[id="{{ id }}"]').val(ui.item.value);
+                            if (typeof(callbackClientId) === typeof (Function)) {
+                                callbackClientId(ui.item.value);
+                            }
                             event.preventDefault();
                         }
                     });
                     if ($('input[id="{{ id }}"]').val() > 0) {
                         // carga el nombre cuando se esta modificando
                         $.ajax({
-                            url: '{{ ajax_url_data }}?q=' + $('input[id="{{ id }}"]').val(),
+                            url: '{{ ajax_url_data }}',
+                            data: {
+                                q: $('input[id="{{ id }}"]').val()
+                            },
                             success: function (result) {
                                 if (result != null && result.results != null && result.results.length > 0) {
                                     $('input[id="{{ id }}_search"]').val(result.results[0].name);