|
@@ -18,8 +18,9 @@ This code manage the many-to-[one|many] association field popup
|
|
|
|
|
|
{% autoescape false %}
|
|
|
|
|
|
-<script>
|
|
|
- <!-- edit many association -->
|
|
|
+<!-- edit many association -->
|
|
|
+
|
|
|
+<script type="text/javascript">
|
|
|
|
|
|
{#
|
|
|
handle link click in a list :
|
|
@@ -94,6 +95,7 @@ This code manage the many-to-[one|many] association field popup
|
|
|
jQuery(form).ajaxSubmit({
|
|
|
type: form.attr('method'),
|
|
|
url: form.attr('action'),
|
|
|
+ dataType: 'html',
|
|
|
data: {_xml_http_request: true},
|
|
|
success: function(html) {
|
|
|
field_dialog_{{ id }}.html(html);
|
|
@@ -134,6 +136,7 @@ This code manage the many-to-[one|many] association field popup
|
|
|
// retrieve the form element from the related admin generator
|
|
|
jQuery.ajax({
|
|
|
url: a.attr('href'),
|
|
|
+ dataType: 'html',
|
|
|
success: function(html) {
|
|
|
|
|
|
Admin.log('[{{ id }}|field_dialog_form_add] ajax success', field_dialog_{{ id }});
|
|
@@ -151,6 +154,7 @@ This code manage the many-to-[one|many] association field popup
|
|
|
height: 'auto',
|
|
|
width: 650,
|
|
|
modal: true,
|
|
|
+ autoOpen: true,
|
|
|
resizable: false,
|
|
|
title: '{{ sonata_admin.field_description.associationadmin.label }}',
|
|
|
close: function(event, ui) {
|
|
@@ -270,7 +274,7 @@ This code manage the many-to-[one|many] association field popup
|
|
|
field_dialog_{{ id }} = jQuery("#field_dialog_{{ id }}");
|
|
|
|
|
|
// move the dialog as a child of the root element, nested form breaks html ...
|
|
|
- jQuery(document).append(field_dialog_{{ id }});
|
|
|
+ jQuery(document.body).append(field_dialog_{{ id }});
|
|
|
|
|
|
Admin.log('[{{ id }}|field_dialog] move dialog container as a document child');
|
|
|
}
|
|
@@ -281,21 +285,18 @@ This code manage the many-to-[one|many] association field popup
|
|
|
#}
|
|
|
// this function initialize the popup
|
|
|
// this can be only done this way has popup can be cascaded
|
|
|
- function start_field_dialog_form_add_{{ id }}(event) {
|
|
|
-
|
|
|
- var targetElement = Admin.stopEvent(event);
|
|
|
+ function start_field_dialog_form_add_{{ id }}(link) {
|
|
|
|
|
|
- // remove the html event a
|
|
|
- var a = jQuery(targetElement).closest('a');
|
|
|
- a.removeAttr('onclick');
|
|
|
+ // remove the html event
|
|
|
+ link.onclick = null;
|
|
|
|
|
|
initialize_popup_{{ id }}();
|
|
|
|
|
|
- // add the jQuery event to the a element
|
|
|
- a.click(field_dialog_form_add_{{ id }});
|
|
|
-
|
|
|
- // trigger the event
|
|
|
- a.trigger('click');
|
|
|
+ // add the jQuery event to the a element
|
|
|
+ jQuery(link)
|
|
|
+ .click(field_dialog_form_add_{{ id }})
|
|
|
+ .trigger('click')
|
|
|
+ ;
|
|
|
|
|
|
return false;
|
|
|
}
|
|
@@ -309,34 +310,29 @@ This code manage the many-to-[one|many] association field popup
|
|
|
#}
|
|
|
// this function initialize the popup
|
|
|
// this can be only done this way has popup can be cascaded
|
|
|
- function start_field_dialog_form_list_{{ id }}(event) {
|
|
|
- var targetElement = Admin.stopEvent(event);
|
|
|
+ function start_field_dialog_form_list_{{ id }}(link) {
|
|
|
|
|
|
- // remove the html event a
|
|
|
- var a = jQuery(targetElement).closest('a');
|
|
|
- a.removeAttr('onclick');
|
|
|
+ link.onclick = null;
|
|
|
|
|
|
initialize_popup_{{ id }}();
|
|
|
|
|
|
// add the jQuery event to the a element
|
|
|
- a.click(field_dialog_form_list_{{ id }});
|
|
|
-
|
|
|
- // trigger the event
|
|
|
- a.trigger('click');
|
|
|
+ jQuery(link)
|
|
|
+ .click(field_dialog_form_list_{{ id }})
|
|
|
+ .trigger('click')
|
|
|
+ ;
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- function remove_selected_element_{{ id }}(event) {
|
|
|
- var targetElement = Admin.stopEvent(event);
|
|
|
-
|
|
|
- // remove the html event a
|
|
|
- var a = jQuery(targetElement).closest('a');
|
|
|
- a.removeAttr('onclick');
|
|
|
+ function remove_selected_element_{{ id }}(link) {
|
|
|
|
|
|
- a.click(field_remove_element_{{ id}});
|
|
|
+ link.onclick = null;
|
|
|
|
|
|
- a.trigger('click');
|
|
|
+ jQuery(link)
|
|
|
+ .click(field_remove_element_{{ id}})
|
|
|
+ .trigger('click')
|
|
|
+ ;
|
|
|
|
|
|
return false;
|
|
|
}
|
|
@@ -378,7 +374,8 @@ This code manage the many-to-[one|many] association field popup
|
|
|
|
|
|
{% endif %}
|
|
|
|
|
|
- <!-- / edit many association -->
|
|
|
+
|
|
|
</script>
|
|
|
+<!-- / edit many association -->
|
|
|
|
|
|
{% endautoescape %}
|