{% put scripts %}
    <script>
        $(function () {
            var $body = $('body');
            $body.on('click', '.mall-address-selector--{{ __SELF__.type }} .js-change-address', function () {
                $.request('{{ __SELF__ }}::onChangeAddress', {
                    update: {'{{ __SELF__ }}::changeAddress': '#' + $(this).closest('.mall-address').attr('id')},
                    loading: $.oc.stripeLoadIndicator,
                })
            });
            $body.on('change', '.mall-address-selector--{{ __SELF__.type }} #mall_address_id', function () {
                if (this.value === 'new') {
                    document.location.href = '{{ __SELF__.addressPage | page({
                        address: "new",
                        redirect: __SELF__.property('redirect'),
                        set: __SELF__.type,
                    }) }}'
                }
            });
        })
    </script>
{% endput %}