123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- {#
- This file is part of the Sonata package.
- (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
- For the full copyright and license information, please view the LICENSE
- file that was distributed with this source code.
- #}
- {#
- This code manage the one-to-many association field popup
- #}
- {% autoescape false %}
- <script>
- <!-- edit one association -->
- // handle the add link
- var field_add_{{ admin.uniqid }}_{{ field_element.id }} = function(event) {
- event.preventDefault();
- var form = jQuery(this).closest('form');
- // the ajax post
- jQuery.ajax({
- url: '{{ url('sonata_base_application_append_form_element', {
- 'code': admin.root.code,
- 'elementId': field_element.id,
- 'objectId': admin.root.subject.id,
- 'uniqid': admin.root.uniqid
- }) }}',
- type: "POST",
- data: form.serializeArray(),
- success: function(html) {
- jQuery('#sonata-ba-field-container-{{ admin.uniqid }}-{{ field_element.id}}').replaceWith(html);
- }
- });
- return false;
- };
- var field_widget_{{ admin.uniqid }}_{{ field_element.id }} = false;
- // this function initialize the popup
- // this can be only done this way has popup can be cascaded
- function start_field_retrieve_{{ admin.uniqid }}_{{ field_element.id }}(event) {
- event.preventDefault();
- // remove the html event a
- var a = jQuery(event.target).closest('a');
- a.attr('onclick', '');
- // initialize component
- field_widget_{{ admin.uniqid }}_{{ field_element.id }} = jQuery("#field_widget_{{ admin.uniqid }}_{{ field_element.id}}");
- // add the jQuery event to the a element
- a.click(field_add_{{ admin.uniqid }}_{{ field_element.id }});
- // trigger the event
- a.trigger('click');
- return false;
- }
- <!-- edit one association -->
-
- </script>
- {% endautoescape %}
|