Updated JS (sync with SonataDoctrineORMBundle)

At the end I copy-pasted their code, there were quite few differences.

However, it fixed at least one issue I have with modals, where a button triggers a ajax-request from main form and inserts the response into the modal. Its quite annoying :wink: