ソースを参照

#974 prevent multiple javascript refresh when reloading the "initial state" of a ticket.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3379 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 10 年 前
コミット
cd1246306b
1 ファイル変更2 行追加1 行削除
  1. 2 1
      application/cmdbabstract.class.inc.php

+ 2 - 1
application/cmdbabstract.class.inc.php

@@ -1854,7 +1854,8 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
 			$aDependencies = MetaModel::GetDependentAttributes($sClass, $sAttCode); // List of attributes that depend on the current one
 			if (count($aDependencies) > 0)
 			{
-				$oPage->add_ready_script("$('#$iId').bind('change', function(evt, sFormId) { return oWizardHelper{$sFormPrefix}.UpdateDependentFields(['".implode("','", $aDependencies)."']) } );\n"); // Bind to a custom event: validate
+				// Unbind first to avoid duplicate event handlers in case of reload of the whole (or part of the) form
+				$oPage->add_ready_script("$('#$iId').unbind('change.dependencies').bind('change.dependencies', function(evt, sFormId) { return oWizardHelper{$sFormPrefix}.UpdateDependentFields(['".implode("','", $aDependencies)."']) } );\n"); // Bind to a custom event: validate
 			}
 		}
 		return "<div>{$sHTMLValue}</div>";