When a field accepts multiple values, the admin form adds a button "Add another item". Mousedown submits a POST to /system/ajax to get another field (i'm using multifield here).
I'd like to hook into the javascript completed event to do some custom handling on those additional fields.
How can I most easily hook these ajax calls for javascript callback and reference to the block being added? Is it possible without PHP?
$( document ).ajaxComplete(function( event, xhr, settings ) { .. }
$(document).ajaxComplete(function(event,xhr,settings){ if (settings.url.indexOf("/system/ajax") > -1) { var data = xhr.responseText; if (data) { data = JSON.parse(data); if (data.length > 0 && typeof data[1].data != 'undefined') { data = data[1].data; if (data.indexOf('field-search-radius') > -1) { console.log('i found you!'); } } } } });