public static function GetForm($form_params, $container_id, $ajax_id, $bReplace = true, $bShadow = true) { static $rndGenerator = null; if (!$rndGenerator) { $rndGenerator = new \Bitrix\Main\Type\RandomSequence("BX_AJAX"); } $rnd = $rndGenerator->randString(6); return ' <form ' . trim($form_params) . '><input type="hidden" name="' . BX_AJAX_PARAM_ID . '" id="' . BX_AJAX_PARAM_ID . '_' . $ajax_id . '_' . $rnd . '" value="' . $ajax_id . '" /><input type="hidden" name="AJAX_CALL" value="Y" /><script type="text/javascript"> function _processform_' . $rnd . '(){ var obForm = top.BX(\'' . BX_AJAX_PARAM_ID . '_' . $ajax_id . '_' . $rnd . '\').form; top.BX.bind(obForm, \'submit\', function() {' . CAjax::GetFormEventValue($container_id, $bReplace, $bShadow, '"') . '}); top.BX.removeCustomEvent(\'onAjaxSuccess\', _processform_' . $rnd . '); } if (top.BX(\'' . BX_AJAX_PARAM_ID . '_' . $ajax_id . '_' . $rnd . '\')) _processform_' . $rnd . '(); else top.BX.addCustomEvent(\'onAjaxSuccess\', _processform_' . $rnd . '); </script>'; }
function GetForm($form_params, $container_id, $ajax_id, $bReplace = true, $bShadow = true) { $rnd = rand(0, 100000); return ' <form ' . trim($form_params) . '><input type="hidden" name="' . BX_AJAX_PARAM_ID . '" id="' . BX_AJAX_PARAM_ID . '_' . $ajax_id . '_' . $rnd . '" value="' . $ajax_id . '" /><input type="hidden" name="AJAX_CALL" value="Y" /><script type="text/javascript"> function _processform_' . $rnd . '(){ var obForm = top.BX(\'' . BX_AJAX_PARAM_ID . '_' . $ajax_id . '_' . $rnd . '\').form; top.BX.bind(obForm, \'submit\', function() {' . CAjax::GetFormEventValue($container_id, $bReplace, $bShadow, '"') . '}); top.BX.removeCustomEvent(\'onAjaxSuccess\', _processform_' . $rnd . '); } if (top.BX(\'' . BX_AJAX_PARAM_ID . '_' . $ajax_id . '_' . $rnd . '\')) _processform_' . $rnd . '(); else top.BX.addCustomEvent(\'onAjaxSuccess\', _processform_' . $rnd . '); </script>'; }