Преглед на файлове

bug js fix: erreur dans les variables (logique de prog). On précise maintenant l'id de l'élément que l'on doit modifier après post en ajax.

bastien преди 12 години
родител
ревизия
b952b2bdac

+ 2 - 1
src/Muzich/CoreBundle/Controller/ElementController.php Целия файл

@@ -80,7 +80,7 @@ class ElementController extends Controller
80 80
   /**
81 81
    *
82 82
    */
83
-  public function updateAction($element_id)
83
+  public function updateAction($element_id, $dom_id)
84 84
   {
85 85
     if (($response = $this->mustBeConnected()))
86 86
     {
@@ -142,6 +142,7 @@ class ElementController extends Controller
142 142
     {
143 143
       return $this->jsonResponse(array(
144 144
         'status'  => $status,
145
+        'dom_id'  => $dom_id,
145 146
         'html'    => $html,
146 147
         'errors'  => $errors
147 148
       ));

+ 1 - 1
src/Muzich/CoreBundle/Resources/config/routing.yml Целия файл

@@ -74,7 +74,7 @@ element_edit:
74 74
   defaults: { _controller: MuzichCoreBundle:Element:edit }
75 75
 
76 76
 element_update:
77
-  pattern: /element/{element_id}/update
77
+  pattern: /element/{element_id}/update/{dom_id}
78 78
   defaults: { _controller: MuzichCoreBundle:Element:update }
79 79
   
80 80
 element_remove:

+ 7 - 1
src/Muzich/CoreBundle/Resources/views/Element/ajax.element.edit.html.twig Целия файл

@@ -1,5 +1,11 @@
1 1
 
2
-<form novalidate class="edit_element" name="{{ form_name }}" action="{{ path('element_update', {'element_id': element_id}) }}" method="post" {{ form_enctype(form) }}>
2
+<form 
3
+  novalidate
4
+  class="edit_element" 
5
+  name="{{ form_name }}" 
6
+  action="{{ path('element_update', {'element_id': element_id, 'dom_id': 'element_' ~ element_id}) }}" 
7
+  method="post" {{ form_enctype(form) }}
8
+>
3 9
 
4 10
   {% include "MuzichCoreBundle:Element:form.edit.html.twig" with { 
5 11
     'form'          : form, 

+ 3 - 0
web/bundles/muzichcore/js/muzich.js Целия файл

@@ -587,6 +587,7 @@ $(document).ready(function(){
587 587
       
588 588
       // On rend ce formulaire ajaxFormable
589 589
       $('form[name="'+response.form_name+'"] input[type="submit"]').live('click', function(){
590
+        li = $(this).parent('form').parent('li');
590 591
         li.prepend(div_loader);
591 592
         li.find('img.element_loader').show();
592 593
       });
@@ -597,6 +598,8 @@ $(document).ready(function(){
597 598
           $(location).attr('href', url_index);
598 599
         }
599 600
         
601
+        li = $('li#'+response.dom_id);
602
+        
600 603
         if (response.status == 'success')
601 604
         {
602 605
           li.html(response.html);