1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- {#
- 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_{{ id }} = function(event) {
- event.preventDefault();
- event.stopPropagation();
- var form = jQuery(this).closest('form');
- // the ajax post
- jQuery(form).ajaxSubmit({
- url: '{{ url('sonata_admin_append_form_element', {
- 'code': sonata_admin.admin.root.code,
- 'elementId': id,
- 'objectId': sonata_admin.admin.root.subject.id,
- 'uniqid': sonata_admin.admin.root.uniqid
- }) }}',
- type: "POST",
- data: { _xml_http_request: true },
- success: function(html) {
- jQuery('#field_container_{{ id }}')
- .replaceWith(html) // replace the html
- .trigger('sonata.add_element');
- }
- });
- return false;
- };
- var field_widget_{{ id }} = false;
- // this function initialize the popup
- // this can be only done this way has popup can be cascaded
- function start_field_retrieve_{{ id }}(event) {
- event.preventDefault();
- // remove the html event a
- var a = jQuery(event.target).closest('a');
- a.attr('onclick', '');
- // initialize component
- field_widget_{{ id }} = jQuery("#field_widget_{{ id }}");
- // add the jQuery event to the a element
- a.click(field_add_{{ id }});
- // trigger the event
- a.trigger('click');
- return false;
- }
- <!-- edit one association -->
- </script>
- {% endautoescape %}
|