Browse Source

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 13 years ago
parent
commit
b952b2bdac

+ 2 - 1
src/Muzich/CoreBundle/Controller/ElementController.php View File

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

+ 1 - 1
src/Muzich/CoreBundle/Resources/config/routing.yml View File

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

+ 7 - 1
src/Muzich/CoreBundle/Resources/views/Element/ajax.element.edit.html.twig View File

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
   {% include "MuzichCoreBundle:Element:form.edit.html.twig" with { 
10
   {% include "MuzichCoreBundle:Element:form.edit.html.twig" with { 
5
     'form'          : form, 
11
     'form'          : form, 

+ 3 - 0
web/bundles/muzichcore/js/muzich.js View File

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