Переглянути джерело

Added 'sonata-admin-setup-list-modal' event trigger (#4271)

Admin.setup_list_modal now triggers a 'sonata-admin-setup-list-modal' jQuery event
Docs have been updated
Romain Sanchez 8 роки тому
батько
коміт
f548f04670
2 змінених файлів з 9 додано та 0 видалено
  1. 7 0
      Resources/doc/reference/form_types.rst
  2. 2 0
      Resources/public/Admin.js

+ 7 - 0
Resources/doc/reference/form_types.rst

@@ -100,6 +100,13 @@ btn_add, btn_list, btn_delete and btn_catalogue:
 
     If you need to use a sortable ``sonata_type_model`` check the :doc:`../cookbook/recipe_sortable_sonata_type_model` page.
 
+.. note::
+
+    When using ``sonata_type_model`` with ``btn_add``, a jQuery event will be
+    triggered when a child form is added to the DOM
+    (``sonata-admin-setup-list-modal`` by default and
+    ``sonata-admin-append-form-element`` when using ``edit:inline``).
+
 sonata_type_model_hidden
 ^^^^^^^^^^^^^^^^^^^^^^^^
 Setting a field type of ``sonata_type_model_hidden`` will use an instance of

+ 2 - 0
Resources/public/Admin.js

@@ -55,6 +55,8 @@ var Admin = {
             padding: 15,
             overflow: 'auto'
         });
+      
+        jQuery(modal).trigger('sonata-admin-setup-list-modal');
     },
     setup_select2: function(subject) {
         if (window.SONATA_CONFIG && window.SONATA_CONFIG.USE_SELECT2) {